Wildfly 8.2.0 包级日志类别
Wildfly 8.2.0 package level logging category
我在尝试使用更通用的 appender 时遇到问题,它应该可以轻松捕获我的大多数包记录器。
我有一个 CDI 应用程序,其中包含从我的生产者注入的记录器,其代码如下
package com.mycompany.common.producers;
import java.util.logging.Logger;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
public class LoggerProducer {
@Produces
public Logger produceLogger(InjectionPoint injectionPoint){
return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
}
}
很好,当我定义我的 类 时,就像
package com.mycompany.rest;
class RestService {
@Inject
private Logger log;
public void myLogTest(){
log.fine("My log line");
}
}
和任何 类 我定义的一切都按预期工作
但
我对通用记录器有疑问。
假设我有两个 类
com.mycompany.rest.RestService;
com.mycompany.rest.SecondRestService
当我在Wildfly中定义一个appender时,代码类似于
<logger category="com.mycompany.rest.RestService" use-parent-handlers="true">
<level name="FINE"/>
<handlers>
<handler name="MYCOMPANY"/>
</handlers>
</logger>
<logger category="com.mycompany.rest.SecondRestService" use-parent-handlers="true">
<level name="FINE"/>
<handlers>
<handler name="MYCOMPANY"/>
</handlers>
</logger>
一切正常,但我想知道,如果我配置这个
<logger category="com.mycompany.rest" use-parent-handlers="true">
<level name="FINE"/>
<handlers>
<handler name="MYCOMPANY"/>
</handlers>
</logger>
根本不起作用。我需要有一个包级别的记录器
请帮忙!
目前我的评论是正确的,但我在配置中缺少处理程序,现在我添加了处理程序,记录器工作正常。
我在尝试使用更通用的 appender 时遇到问题,它应该可以轻松捕获我的大多数包记录器。 我有一个 CDI 应用程序,其中包含从我的生产者注入的记录器,其代码如下
package com.mycompany.common.producers;
import java.util.logging.Logger;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
public class LoggerProducer {
@Produces
public Logger produceLogger(InjectionPoint injectionPoint){
return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
}
}
很好,当我定义我的 类 时,就像
package com.mycompany.rest;
class RestService {
@Inject
private Logger log;
public void myLogTest(){
log.fine("My log line");
}
}
和任何 类 我定义的一切都按预期工作 但 我对通用记录器有疑问。 假设我有两个 类
com.mycompany.rest.RestService; com.mycompany.rest.SecondRestService
当我在Wildfly中定义一个appender时,代码类似于
<logger category="com.mycompany.rest.RestService" use-parent-handlers="true">
<level name="FINE"/>
<handlers>
<handler name="MYCOMPANY"/>
</handlers>
</logger>
<logger category="com.mycompany.rest.SecondRestService" use-parent-handlers="true">
<level name="FINE"/>
<handlers>
<handler name="MYCOMPANY"/>
</handlers>
</logger>
一切正常,但我想知道,如果我配置这个
<logger category="com.mycompany.rest" use-parent-handlers="true">
<level name="FINE"/>
<handlers>
<handler name="MYCOMPANY"/>
</handlers>
</logger>
根本不起作用。我需要有一个包级别的记录器 请帮忙!
目前我的评论是正确的,但我在配置中缺少处理程序,现在我添加了处理程序,记录器工作正常。