日期:2014-05-18  浏览次数:20675 次

mybatis打印sql语句

请教下mybatis 如何打印sql语句 logs.properties 已经设置为debug了

------解决方案--------------------
引用:
引用:

帮顶,我也在研究

google一查全是ibatis的!唉……

mybatis -ibatis
去掉ibatis嘛
------解决方案--------------------
引用:
唉……每次问问题都是没有答案的!

贴上我的log4j.properties

#logger level default is INFO
log4j.rootLogger=info,console,file

#append to console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d %p - %m%n

#append to file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=/demo.log
log4j.appender.file.MaxFileSize=1MB
log4j.appender.file.MaxBackupIndex=10000
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d %p - %m%n


#ibatis logger config
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,stdout

这个是ibatis的大印sql 不知道mbatis行不行 试试

------解决方案--------------------
info  换成debug  试试
一般debug信息里肯定会有sql语句以及相关事务
------解决方案--------------------
mybatis其实就是ibatis的更高版本而已,你就直接搜ibatis的,应该有帮助,最好去查文档,ibatis用的人也不是很多,mybatis还算比较新,估计用的人更少了
------解决方案--------------------
MyBatis自己内部使用的是Log4j,但实际上支持用户使用各种Log技术。如果配置正确的话,也就是启用debug级别即可打印所有的MyBatis的语句。比如,在我的web程序中,使用logback,maven依赖如下:

    <!--log-begin-->
    <dependency>
      <groupId>org.slf4j</groupId>