如何在控制台打印出mybatis sql语句日志

2/22/2017来源:ASP.NET技巧人气:2375

来源:http://blog.csdn.net/wdq892157341/article/details/50836190

1.首先配置 log4j日志文件 

[html] view plain copy #mybatis日志范围   log4j.logger.com.nes=TRACE   #ibatis配置   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.org.mybatis=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     2.导入依赖日志包 log4j

[html] view plain copy  在CODE上查看代码片派生到我的代码片 <!-- SLFJ 可依赖到log4j-->   <dependency>       <groupId>org.slf4j</groupId>        <artifactId>slf4j-log4j12</artifactId>       <version>1.6.4</version>   </dependency>   <dependency>         <groupId>log4j</groupId>         <artifactId>log4j</artifactId>         <version>1.2.14</version>     </dependency>     <dependency>            <groupId>org.slf4j</groupId>           <artifactId>slf4j-api</artifactId>            <version>1.7.7</version>     </dependency>