MyBatis:log4j配置

LOG_DIR=D:/logs/mybatis

#########定义命令行接收器#####################
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=[%d{MM-dd HH:mm:ss}] %m - \u3010%p\u3011 %l thread: %t%n

#########MainListener类日志输出位置#####################
log4j.category.com.xjb.MainListener = all,MainListener,Console 

#########定义一个文件接收器用于接收com.xjb.MainListener类日志#####################
log4j.appender.MainListener=org.apache.log4j.RollingFileAppender
log4j.appender.MainListener.File=${LOG_DIR}/pingan.log
log4j.appender.MainListener.MaxFileSize=5000000
log4j.appender.MainListener.layout=org.apache.log4j.PatternLayout
log4j.appender.MainListener.layout.ConversionPattern=[%d{MM-dd HH:mm:ss}] %m - \u3010%p\u3011 %l thread: %t%n


#########定义sql文件接收器#####################
log4j.appender.sql=org.apache.log4j.RollingFileAppender
log4j.appender.sql.File=${LOG_DIR}/sql.log
log4j.appender.sql.MaxFileSize=5000000
log4j.appender.sql.layout=org.apache.log4j.PatternLayout
log4j.appender.sql.layout.ConversionPattern=[%d{MM-dd HH:mm:ss}] %m - \u3010%p\u3011 %l thread: %t%n

#########此处的Person对应mapper映射文件namespace属性中的Person(<mapper namespace="Person">)这个命名空间下的sql debug信息输出#####################
log4j.logger.Person=debug,sql,Console
posted @ 2019-01-15 14:32  xuejianbest  阅读(908)  评论(0编辑  收藏  举报