尝试以下配置:
log4j.rootLogger=TRACE, stdoutlog4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.appender.stdout.layout=org.apache.log4j.PatternLayoutlog4j.appender.stdout.layout.ConversionPattern=%d [%24F:%t:%L] - %m%nlog4j.appender.debugLog=org.apache.log4j.FileAppenderlog4j.appender.debugLog.File=logs/debug.loglog4j.appender.debugLog.layout=org.apache.log4j.PatternLayoutlog4j.appender.debugLog.layout.ConversionPattern=%d [%24F:%t:%L] - %m%nlog4j.appender.reportsLog=org.apache.log4j.FileAppenderlog4j.appender.reportsLog.File=logs/reports.loglog4j.appender.reportsLog.layout=org.apache.log4j.PatternLayoutlog4j.appender.reportsLog.layout.ConversionPattern=%d [%24F:%t:%L] - %m%nlog4j.category.debugLogger=TRACE, debugLoglog4j.additivity.debugLogger=falselog4j.category.reportsLogger=DEBUG, reportsLoglog4j.additivity.reportsLogger=false
然后相应地用Java代码配置记录器:
static final Logger debugLog = Logger.getLogger("debugLogger");static final Logger resultLog = Logger.getLogger("reportsLogger");
你要输出到
stdout吗?如果不是,请将第一行更改
log4j.properties为:
log4j.rootLogger=OFF
并摆脱
stdout界限。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)