在本地开发调试过程中,有时候需要输出PreparedStatement 的调用的SQL,也就是将每一个SQL调用语句都输出方便程序调试。
1.使用mybatis-plus配置实现SQL日志输出
# 配置slq打印日志
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
2.使用logback配置实现SQL日志输出
其中 level: 对应mybatis的mapper映射类所在的包。
#输出SQL
logging:
pattern:
console: "%d - %msg%n"
file:
path: logs
level:
com.example.studentsapp.mapper: debug
# 配置slq打印日志
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl