LOG4J 配置

log4j.rootLogger = info, console0, consoleX

#不同的包设置不同的LOG输出级别
log4j.logger.subpackage = warn, file0, fileX
#不继承父LOGGER的Appender
log4j. additivity.subpackage = false

#Console0
log4j.appender.console0=org.apache.log4j.ConsoleAppender
log4j.appender.console0.layout=org.apache.log4j.PatternLayout
log4j.appender.console0.layout.ConversionPattern=[%-5p] [%d{HH:mm:ss}] %c - %m%n

#File0
log4j.appender.file0=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file0.layout=org.apache.log4j.PatternLayout
log4j.appender.file0.layout.ConversionPattern=[%-5p] [%d{HH:mm:ss}] %c - %m%n
log4j.appender.file0.datePattern='.'yyyy-MM-dd
#只输出ERROR级别的LOG到指定文件
log4j.appender.file0. Threshold = ERROR
#log4j.appender.file0.append=true
log4j.appender.file0.File=${webApp.root}/WEB-INF/logs/info.log


XML方式:
<filter class="org.apache.log4j.varia.LevelMatchFilter"> 
  <param name="LevelToMatch" value="DEBUG"/> 
</filter>

<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMax" value="INFO" />
<param name="LevelMin" value="INFO" />
</filter>

参考:
http://blog.csdn.net/shuimuzhiyuan/article/details/9381701
http://blog.csdn.net/wangchsh2008/article/details/8812857
http://blog.csdn.net/junshao90/article/details/8268522

你可能感兴趣的:(log4j)