如下配置即可,要点建红色部分 1.建一个单独的category 2.在单独的category的配置增加log4j.additivity.a2=false
log4j.rootCategory=INFO, a1
log4j.category=INFO, a2
log4j.appender.a1=org.apache.log4j.DailyRollingFileAppender
log4j.appender.a1.Append=true
log4j.appender.a1.Threshold=INFO
log4j.appender.a1.DatePattern='.'yyyy_MM_dd'.log'
log4j.appender.a1.File=./logs/a1.log
log4j.appender.a1.layout=org.apache.log4j.PatternLayout
log4j.appender.a1.layout.ConversionPattern=[%d{yyyy.MM.dd HH:mm:ss,SSS}][%t][%c][%M](%L)[%p] - %m%n
log4j.logger.a2=INFO,a2
log4j.appender.a2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.a2.File=./logs/a2.log
log4j.appender.a2.DatePattern='.'yyyy_MM_dd'.log'
log4j.appender.a2.layout=org.apache.log4j.PatternLayout
log4j.appender.a2.layout.ConversionPattern=[%d{yyyy.MM.dd HH:mm:ss,SSS}][%t][%c][%M](%L)[%p] - %m%n
log4j.additivity.a2=false