Log4j样例配置
作者:互联网
Log4j样例配置
#配置根Logger,其语法为:log4j.rootLogger=[level],appenderName1,appenderName2,...
#level是日志记录的优先级,分为OFF,TRACE,DEBUG,INFO,WARN,ERROR,FATAL,ALL
#Log4j建议只使用四个级别,优先级从低到高分别是DEBUG,INFO,WARN,ERROR
log4j.rootLogger=debug,console,FILE
#配置控制台appender
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [%c](%L)-[%p] %m%n
#配置文件appender
log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender
log4j.appender.FILE.File=D:/logs/log4j.log
log4j.appender.FILE.Encoding=UTF-8
log4j.appender.FILE.Append=true
log4j.appender.FILE.Threshold=debug
log4j.appender.FILE.DatePattern='.'yyyy-MM-dd
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m%n
#配置自定义Logger: mybatis
log4j.logger.com.mybatis=DEBUG
log4j.logger.com.mybatis.common.jdbc.SimpleDataSource=DEBUG
log4j.logger.com.mybatis.common.jdbc.ScriptRunner=DEBUG
log4j.logger.com.mybatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
#配置自定义Logger: java.sql
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
log4j.logger.java.sql.ResultSet=DEBUG
#配置用户自定义Logger: com.test.ctrl,com.test.ctrl这个名称的Logger日志将打印到D:/logs/mylogger.log
log4j.logger.com.test.ctrl=DEBUG,mylogger
log4j.appender.mylogger.Encoding=UTF-8
log4j.appender.mylogger=org.apache.log4j.DailyRollingFileAppender
log4j.appender.mylogger.File=D:/logs/mylogger.log
log4j.appender.mylogger.DatePattern='_'yyyy-MM-dd
log4j.appender.mylogger.layout=org.apache.log4j.PatternLayout
log4j.appender.mylogger.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m -(:%L)%n
标签:mylogger,配置,样例,Log4j,FILE,DEBUG,log4j,logger,appender 来源: https://blog.csdn.net/geekooler/article/details/100852559