Java log4j 配置示例
示例配置
#levels: debug, info, warn, error, fatal
log4j.rootLogger=debug,info,stdout,infoLog,errorLog
# System.out
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m %n
# DEBUG
log4j.appender.infoLog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.infoLog.File=C:/log/log.log
log4j.appender.infoLog.Append=true
log4j.appender.infoLog.Threshold=DEBUG
log4j.appender.infoLog.layout=org.apache.log4j.PatternLayout
log4j.appender.infoLog.layout.ConversionPattern=%d %p [%c] - %m %n
log4j.appender.infoLog.encoding=UTF-8
# ERROR
log4j.appender.errorLog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.errorLog.File=C:/log/log.log
log4j.appender.errorLog.Append=true
log4j.appender.errorLog.Threshold=ERROR
log4j.appender.errorLog.layout=org.apache.log4j.PatternLayout
log4j.appender.errorLog.layout.ConversionPattern=%d %p [%c] - %m %n
log4j.appender.errorLog.encoding=UTF-8
# SQL
log4j.logger.java.sql.ResultSet=DEBUG
log4j.logger.org.apache=DEBUG
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG