mytatis打印SQL语句
来源:互联网 发布:达内培训 java测试 编辑:程序博客网 时间:2024/06/04 17:53
mybatis默认使用log4j,当有self4j这个日志jar包存在时会无法打印sql,请移除或者在工程启动时显示设置mybatis使用的日志类
log4j.logger.org.apache.ibatis=debug,stdout
log4j.logger.java.sql=debug,stdout
---------------------------------------------------------------
今天又碰到按照上面那样做了还是没有打印sql,原因在于不可能移除self4j包,因为其他依赖包必须依赖这个包,。。。。不得已又去查资料。
mybatis有如下方法来手动选择日志类,调用后成功打印日志
org.apache.ibatis.logging.LogFactory.useSlf4jLogging();
org.apache.ibatis.logging.LogFactory.useLog4JLogging();
org.apache.ibatis.logging.LogFactory.useJdkLogging();
org.apache.ibatis.logging.LogFactory.useCommonsLogging();
org.apache.ibatis.logging.LogFactory.useStdOutLogging();
注意:If you choose to call one of these methods, you should do so before calling any other MyBatis
method. Also, these methods will only switch to the requested log implementation if that
implementation is available on the runtime classpath. For example, if you try to select Log4J logging
and Log4J is not available at runtime, then MyBatis will ignore the request to use Log4J and will use
it's normal algorithm for discovering logging implementations.
针对红色的那段字。我使用的是spring,在spring启动的时候调用LogFactory.useLog4JLogging();打印成功
log4j.logger.org.apache.ibatis=debug,stdout
log4j.logger.java.sql=debug,stdout
---------------------------------------------------------------
今天又碰到按照上面那样做了还是没有打印sql,原因在于不可能移除self4j包,因为其他依赖包必须依赖这个包,。。。。不得已又去查资料。
mybatis有如下方法来手动选择日志类,调用后成功打印日志
org.apache.ibatis.logging.LogFactory.useSlf4jLogging();
org.apache.ibatis.logging.LogFactory.useLog4JLogging();
org.apache.ibatis.logging.LogFactory.useJdkLogging();
org.apache.ibatis.logging.LogFactory.useCommonsLogging();
org.apache.ibatis.logging.LogFactory.useStdOutLogging();
注意:If you choose to call one of these methods, you should do so before calling any other MyBatis
method. Also, these methods will only switch to the requested log implementation if that
implementation is available on the runtime classpath. For example, if you try to select Log4J logging
and Log4J is not available at runtime, then MyBatis will ignore the request to use Log4J and will use
it's normal algorithm for discovering logging implementations.
针对红色的那段字。我使用的是spring,在spring启动的时候调用LogFactory.useLog4JLogging();打印成功
本文转自http://13146489.iteye.com/blog/1037512
http://mybatis.github.io/mybatis-3/zh/logging.html
- mytatis打印SQL语句
- laravel 打印sql 语句 打印sql语句
- ibatis打印sql语句
- mybatis 打印sql语句
- mybatis 打印sql语句
- ibatis打印sql语句
- MySQL56打印sql语句
- ibatis打印sql语句
- yii打印sql语句
- mybatis3 打印sql语句
- yii打印sql语句
- mybatis打印sql语句
- yii2打印sql语句
- log4j打印sql语句
- 打印 mybatis sql 语句
- Mybatis 打印SQL语句
- Yii 打印SQL语句
- Hibernate打印sql语句
- 大话设计模式原则
- 程序员的出路之一
- HOw to see the oracle explain plan
- js原型 prototype
- 机械硬盘怎么看是否4k对齐
- mytatis打印SQL语句
- 关于编码ansi、GB2312、unicode与utf-8的区别
- ASIHttp
- CDATA和PCDATA
- Spring3.0 单元测试
- Java环境搭建与配置
- 网页下载 iframe
- 360卫士本地提权漏洞——后门利用程序
- 第一次两个技术面笔记