springBoot中info等级通过druid打印sql

我的springBoot是使用logback来输出日志的.

application.yml中log相关配置如下:

logging:
  pattern:
    console: "%d{yyyy-MM-dd HH:mm:ss.SSS} %clr(%5p) %clr([%15.15t]){cyan} %clr(%X{__traceId}){magenta} %clr(%-40.40logger{39}){blue} %clr(:) %m%n"
    file: "%d{yyyy-MM-dd HH:mm:ss.SSS} %5p [%t] %X{__traceId} %-40.40logger{39} : %m%n"
  level:
    com.xxx.xxx.xxx.repository.mybatis.mapper: debug   #设置mapper.java包为debug输出
  file: c:/tmp/xxx-xxx-web/log.log
  file.max-history: 30

如果项目日志等级为info时是不会打印sql语句的(在debug等级下会打印),如果想要在info等级下打印sql需要在application.yml中的

druid配置部分增加以下配置:

druid:
      filter:
        commons-log:
          #data-source-log-enabled: true
          statement-log-enabled: true
          statement-executable-sql-log-enable: true

通过以上配置即可通过druid在日志等级为info的情况下打印sql;

 

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值