mytatis打印SQL语句

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();打印成功
 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值