我的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;

 

 

GitHub 加速计划 / druid / druid
6
3
下载
阿里云计算平台DataWorks(https://help.aliyun.com/document_detail/137663.html) 团队出品,为监控而生的数据库连接池
最近提交(Master分支:1 个月前 )
a71fa6ad - 26 天前
0b375e47 - 1 个月前
Logo

新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐