how to configure logback for Mybatis to print my SQL

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了how to configure logback for Mybatis to print my SQL相关的知识,希望对你有一定的参考价值。

To log SQL statements for particular mybatis mapper set DEBUG (TRACE to see query parameters and results) level for logger with fully qualified mapper name

<logger name="com.mycompany.myapp.mapper.MyMapper" level="DEBUG"/>

注意,这里name是Mapper接口类的全限定名,它只打印出一个接口对应的sql语句。

You can log all SQL statements from all mappers if they are in the same package like this

<logger name="com.mycompany.myapp.mapper" level="DEBUG"/>

这里的name表示的是Mapper接口所在的包名,在这种情况下,这个包中所有的类对应的sql语句都会打印出来。

当不是代理方式而是原始dao接口的方式开发时。name可以使dao接口或到接口所在的包名

<logger name="com.XXX.dao" level="DEBUG"/>

只需要这一个配置就可以了,不需要在<root/>进行配置,况且root对应的level通常是INFO

<root level="INFO">
    <appender-ref ref="ROLLING_FILE"/>
    <appender-ref ref="STDOUT"/>
</root>

 



 

以上是关于how to configure logback for Mybatis to print my SQL的主要内容,如果未能解决你的问题,请参考以下文章

How to configure security of ActiveMQ ?

How to configure postfix to send email via Gmail

How to configure postfix to send email via Gmail

How to configure locales to Unicode in a Docker Ubuntu 14.04 container?

Docker: How to configure Docker with devicemapper

How to Configure the Gradient Boosting Algorithm