欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用springBoot中的info等級(jí)通過(guò)druid打印sql

 更新時(shí)間:2021年09月15日 10:24:25   作者:ai_goodStudent  
這篇文章主要介紹了使用springBoot中的info等級(jí)通過(guò)druid打印sql,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

springBoot info等級(jí)通過(guò)druid打印sql

我的springBoot是使用logback來(lái)輸出日志的。

application.yml中l(wèi)og相關(guān)配置如下

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   #設(shè)置mapper.java包為debug輸出
  file: c:/tmp/xxx-xxx-web/log.log
  file.max-history: 30

如果項(xiàng)目日志等級(jí)為info時(shí)是不會(huì)打印sql語(yǔ)句的(在debug等級(jí)下會(huì)打印),如果想要在info等級(jí)下打印sql需要在application.yml中的

druid配置部分增加以下配置

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

通過(guò)以上配置即可通過(guò)druid在日志等級(jí)為info的情況下打印sql;

使用druid打印出sql的優(yōu)勢(shì)

21:26:52,515 DEBUG druid.sql.Statement:137 - {conn-10005, pstmt-20007} executed. 2.301113 millis. select 
         
    ID, AREA_ID, PARENT_AREA_ID, AREA_NAME, AREA_LEVEL, DESCRIPTION, LAST_UPDATE_TIME, 
    LAST_UPDATE_BY, DELETE_FLAG, DELETE_BY, DELETE_TIME
   
    from RMS_AREA
    where 
    DELETE_FLAG='0'
           
    ORDER BY AREA_ID DESC

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論