As shown below:
log4j.rootLogger=info,stdout,info,debug,warn,error log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n log4j.logger.info=info log4j.appender.info=org.apache.log4j.DailyRollingFileAppender log4j.appender.info.layout=org.apache.log4j.PatternLayout log4j.appender.info.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n log4j.appender.info.datePattern='.'yyyy-MM-dd log4j.appender.logfile.MaxFileSize=5120KB log4j.appender.logfile.MaxBackupIndex=3 log4j.appender.info.Threshold=INFO log4j.appender.info.append=true log4j.appender.info.File=/usr/local/tomcat7/logs/info.log log4j.logger.debug=debug log4j.appender.debug=org.apache.log4j.DailyRollingFileAppender log4j.appender.debug.layout=org.apache.log4j.PatternLayout log4j.appender.debug.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n log4j.appender.debug.datePattern='.'yyyy-MM-dd log4j.appender.logfile.MaxFileSize=5120KB log4j.appender.logfile.MaxBackupIndex=3 log4j.appender.debug.Threshold=DEBUG log4j.appender.debug.append=true log4j.appender.debug.File=/usr/local/tomcat7/logs/debug.log log4j.logger.warn=warn log4j.appender.warn=org.apache.log4j.DailyRollingFileAppender log4j.appender.warn.layout=org.apache.log4j.PatternLayout log4j.appender.warn.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n log4j.appender.warn.datePattern='.'yyyy-MM-dd log4j.appender.logfile.MaxFileSize=5120KB log4j.appender.logfile.MaxBackupIndex=3 log4j.appender.warn.Threshold=WARN log4j.appender.warn.append=true log4j.appender.warn.File=/usr/local/tomcat7/logs/warn.log log4j.logger.error=error log4j.appender.error=org.apache.log4j.DailyRollingFileAppender log4j.appender.error.layout=org.apache.log4j.PatternLayout log4j.appender.error.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n log4j.appender.error.datePattern='.'yyyy-MM-dd log4j.appender.logfile.MaxFileSize=5120KB log4j.appender.logfile.MaxBackupIndex=3 log4j.appender.error.Threshold=ERROR log4j.appender.error.append=true log4j.appender.error.File=/usr/local/tomcat7/logs/error.log
The above is the entire content of the implementation method of Log4j outputting logs to different files by level brought by the editor. I hope everyone will support the PHP Chinese website~
For more related articles on how Log4j outputs logs to different files by level, please pay attention to the PHP Chinese website!