mybatis3.1.1 配置log4j 不能输出mybatis的sql语句

JAVA_NINA 发布于 2016/09/30 15:25
阅读 766
收藏 0

项目采用Spring3.2.5、struts2.3.15.3、hibernate4.2.7(主)、mybatis3.1.1(从:负责查询)架构,配置了jdbc.properties配置文件,hibernate、个人类里的日志都能正确输出,而mybatis运行的sql却不能正确输出,百度了好久不能解决,我把maven依赖和jdbc.properties配置文件贴到下面,请高手帮忙解答。

maven部分依赖如下(只体现spring和log4j版本):


<!-- 加入mybatis3.1.1 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.1.1</version> </dependency> <!-- 加入mybatis-spring插件 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.5</version> </dependency>

log4j.properties配置如下:

log4j.rootLogger=DEBUG,Console,OneFile,HtmlFile

log4j.logger.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
log4j.logger.org.hibernate.tool.hbm2ddl=DEBUG
#log4j.logger.org.hibernate.SQL=DEBUG
#log4j.logger.org.hibernate.type.descriptor.sql.BasicExtractor=TRACE
log4j.logger.com.aisino.*=DEBUG

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.jdbc.sqlonly=OFF
#log4j.logger.jdbc.sqltiming=INFO
#log4j.logger.jdbc.audit=INFO
#log4j.logger.jdbc.resultset=INFO
#log4j.logger.jdbc.connection=INFO

log4j.logger.java.sql.ResultSet=INFO  
log4j.logger.org.apache=INFO  
log4j.logger.java.sql.Connection=DEBUG  
log4j.logger.java.sql.Statement=DEBUG  
log4j.logger.java.sql.PreparedStatement=DEBUG  


  
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Target=System.out
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.Threshold=INFO
log4j.appender.Console.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH\:mm\:ss,SSS}][%c]%m%n


log4j.appender.OneFile=org.apache.log4j.RollingFileAppender
log4j.appender.OneFile.File=../logs/ws/ws.txt
log4j.appender.OneFile.MaxFileSize=10MB
log4j.appender.OneFile.Threshold=ERROR
log4j.appender.OneFile.layout=org.apache.log4j.PatternLayout
log4j.appender.OneFile.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH\:mm\:ss,SSS}][%c]%m%n

log4j.appender.HtmlFile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.HtmlFile.file=../logs/ws/ws
log4j.appender.HtmlFile.DatePattern='_'yyyy-MM-dd'.html'
log4j.appender.HtmlFile.layout=org.apache.log4j.HTMLLayout
log4j.appender.HtmlFile.Threshold=ERROR





加载中
0
平安北京

log4j.logger.com.xxx=DEBUG

返回顶部
顶部