Springboot项目中Mybatis输出SQL日志的三种方式
作者:mmseoamin日期:2024-02-06

方法一:指定整个mapper包下的日志级别

# application.yml
logging:
  level:
    com.fwzx.dao: debug  #对应到mapper中dao包的路径
 
# 等价于application.properties
logging.level.com.example.demo.mapper=debug

方法二:指定mybatis日志级别

# application.yml
mybatis:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 
# 等价于application.properties
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl

方法三:配置mybatis-config.xml