SpringBoot项目中将MyBatis打印的SQL语句记录在日志文件中:
方法一:
在yml配置如下
# 日志配置
logging:
level:
com.wang: debug
org.springframework: warn
org.apache.ibatis.logging: debug
踩坑点:
com.wang: info时日志不会记录到日志文件中
配置了log-impl 日志也不会记录到日志文件中,该日志只会在控制台打印
mybatis-plus:
configuration:
map-underscore-to-camel-case: true
auto-mapping-behavior: full
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
方法二:
在yml中配置:
# 日志配置
logging:
level:
org.springframework: warn
org.apache.ibatis.logging: debug
在logback中配置:
<logger name="com.wang" level="debug" />
踩坑点:
要是yml文件中配置了com.wang: info,日志也不会记录到日志文件中,因为yml文件的优先级高于logback.xml文件