1

我有 log4j 记录器,需要将名为“ThermoCommandLogger”的记录器发送到单独的文件,仅此而已(不要将其写入输出或标准文件)。我尝试了以下配置,但记录器调试消息继续写入根记录器(尽管它具有 INFO 级别):

# Root logger
log4j.rootLogger=INFO, out, osgi:VmLogAppender

# File appender
log4j.appender.out=org.apache.log4j.RollingFileAppender
log4j.appender.out.layout=org.apache.log4j.PatternLayout
log4j.appender.out.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-        32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
log4j.appender.out.file=${karaf.data}/log/servicemix.log
log4j.appender.out.append=true
log4j.appender.out.maxFileSize=10MB
log4j.appender.out.maxBackupIndex=10


#DRF appender
log4j.appender.drf=org.apache.log4j.RollingFileAppender
log4j.appender.drf.layout=org.apache.log4j.PatternLayout
log4j.appender.drf.layout.ConversionPattern=%d{ABSOLUTE} | %m%n
log4j.appender.drf.file=${karaf.data}/log/drfx.log
log4j.appender.drf.append=true   


#Log thermo commands to separate file
log4j.logger.ThermoCommandLogger=DEBUG, drf

谢谢

4

1 回答 1

2

您需要将“ThermoCommandLogger”记录器的可加性设置为“false”,这样您将停止日志消息在记录器链中的流动。您可以切换到 xml 配置文件,例如,请参见:log4j and weblogic: duplicate log messages,或者您可以尝试:

log4j.additivity.ThermoCommandLogger=false
于 2011-08-30T10:07:38.760 回答