首页 > 代码库 > how to configure logback for Mybatis to print my SQL

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