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