#all logger output level is ‘ERROR‘ and output position is stdout #so only write our project‘s DEBUG log and ERROR log of the others log4j.rootLogger=ERROR, stdout ,R #log4j.appender is set output postion #log4j.logger is set some package(some package your want output logger specially)=[output level],[...output position] #log4j.logger.org.springframework=OFF #log4j.logger.org.apache.commons=OFF #log4j.logger.org.apache.struts=OFF #log4j.logger.org.hibernate=OFF #log4j.logger.org.logicalcobwebs=OFF #only write our project‘s log(DEBUG) log4j.logger.com.diantu=DEBUG #in the console log4j.appender.stdout=org.apache.log4j.ConsoleAppender #config stdout position output contain INFO level and up log4j.appender.stdout.Threshold=DEBUG log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=[%-5p] %l:%t - %m %n #in the daily files log4j.appender.R=org.apache.log4j.DailyRollingFileAppender log4j.appender.R.Threshold=DEBUG log4j.appender.R.File=${root.path}/log/EMR.log log4j.appender.R.DatePattern=‘.‘yyyy-MM-dd‘.log‘ log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%d [%-5p] %l:%t - %m %n log4j.logger.com.statestr=DEBUG
原理就是 指定 默认的 Log level 为 ERROR,然后指定我们要输入的日志的 包 的log level 为 DEBUG, 这样就能实现输入我们指定包的 DEBUG 基本的 log 和 其它所有代码的 ERROR 级别的 log.
方便调试。
时间: 2024-11-13 10:28:00