mybatis配置Log4j带不出日志
使用Mybatis的时候,有些时候能输出(主要是指sql,参数,结果)日志。
无法输出日志的时候,无论怎么配置log4j,不管是properties的还是xml的,都不起作用。
log4j.properties
log4j.rootLogger=DEBUG,CONSOLE,FILE,A1
log4j.addivity.org.apache=true
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=DEBUG
log4j.appender.CONSOLE.Target=System.out
log4j.appender.CONSOLE.Encoding=GBK
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.conOut.layout.ConversionPattern=%d %-5p [%c] %m%n
log4j.appender.A1=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A1.File=../logs/laifusiadmin1.log
log4j.appender.A1.Encoding=GBK
log4j.appender.A1.Threshold=DEBUG
log4j.appender.A1.DatePattern='.'yyyy-MM-dd
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L : %m%n
log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender
log4j.appender.FILE.Threshold=ERROR
log4j.appender.FILE.File=./logs/error_Log.log
log4j.appender.FILE.DatePattern='_'yyyy-MM-dd'.log'
#log4j.appender.File.MaxFileSize=100KB
#log4j.appender.File.MaxBackupIndex=100
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%d %t %-5p [%c] %m%n
log4j.logger.com.ibatis = DEBUG
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource = DEBUG
log4j.logger.com.ibatis.common.jdbc.ScriptRunner = DEBUG
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate = DEBUG
log4j.logger.java.sql.Connection = DEBUG
log4j.logger.java.sql.Statement = DEBUG
log4j.logger.java.sql.PreparedStatement = DEBUG
log4j.logger.java.sql.ResultSet =DEBUG
在SqlMapConfig.xml配置文件中添加:
<configuration> <settings> <setting name="logImpl" value="LOG4J"/> </settings> </configuration>
漫人生路上,该放下的要放下,往事如过眼烟云,浅笑则安...