我有 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
谢谢