log4j.rootLogger=debug, stdout, R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%d %5p [%t] (%F:%L) - %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=sip.log
log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d %p %t %c - %m%n
以上是我的log4j配置。如何在单独的日志文件中复制所有异常和警告?我想避免代码mofidications
答案 0 :(得分:0)
只需添加另一个记录器,例如“R2”。
log4j.rootLogger=debug, stdout, R, R2
...
log4j.appender.R2=org.apache.log4j.RollingFileAppender
log4j.appender.R2.File=sip2.log
log4j.appender.R2.Threshold=WARN
...