您的位置:首页技术文章
文章详情页

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

【字号: 日期:2023-04-14 16:00:11浏览:5作者:猪猪

现象

在日志配置文件 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'/>

到此这篇关于springboot logback调整mybatis日志级别无效的解决的文章就介绍到这了,更多相关springboot 调整日志级别无效内容请搜索好吧啦网以前的文章或继续浏览下面的相关文章希望大家以后多多支持好吧啦网!

标签: Spring
相关文章: