软件编程
位置:首页>> 软件编程>> java编程>> springboot logback调整mybatis日志级别无效的解决

springboot logback调整mybatis日志级别无效的解决

作者:王坦.  发布时间:2023-05-03 05:36:21 

标签:springboot,调整日志级别

现象

在日志配置文件 logback-spring.xml 中,无论怎么修改级别,mybatis 的 sql 日志都会打印出来。

原因

在 application.yml 中配置了 mybatis 的自定义日志类,如下:


mybatis:
configuration:
 log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

点进去查看源码,发现 debug 日志级别始终为 true,所以怎么配置都不生效


public boolean isDebugEnabled() {
 return true;
}

public boolean isTraceEnabled() {
 return true;
}

解决方法

屏蔽 application.yml 中配置的 mybatis 自定义日志类,然后在 logback-spring.xml 配置文件中,将 mapper(及 dao)包,配置为 info 级别。


<!-- 修改其他包的日志输出级别 -->
<logger name="com.xxx.xxx.mapper" level="INFO"/>

来源:https://blog.csdn.net/WTUDAN/article/details/103162195

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com