Sometimes it is necessary to print the debug information of the third party jar when checking the problem, if all jars are printed, the log file will be very large, this time can be configured log4j to print only the specified jar debug information or package, and output to a new file.
For example: I only printed here MyBatis below DataSource This package debug information to the Debug.log
Log4j.logger.org.apache.ibatis.datasource.pooled=debug, test1log4j.appender.test1= org.apache.log4j.dailyrollingfileappenderlog4j.appender.test1.file=${webapp.root}logs/ Debug.loglog4j.appender.test1.datepattern= '. ' yyyy-mm-ddlog4j.appender.test1.encoding = utf-8log4j.appender.test1.maxfilesize= 100mblog4j.appender.test1.maxbackupindex=10log4j.appender.test1.threshold =debug log4j.appender.test1.layout=org.apache.log4j.patternlayoutlog4j.appender.test1.layout.conversionpattern=[%t][% -5p]%d{yyyy-mm-dd HH:mm:ss. SSS} [%c{1}.%m]-%m%n
log4j Configuration to print only the debug information for the specified jar or package