Spring Cloud 專案列印Sql日誌
阿新 • • 發佈:2019-01-10
Spring cloud的專案, 預設情況下spring boot使用Logback作為日誌實現的框架,
在application.properties中加入:(com.xxx.xx 是你專案的package)
debug=true logging.level.org.springframework.web=DEBUG logging.level.com.xxx.xxx=DEBUG
然後重啟,就可以看到sql日誌了:
2017-11-10 13:39:24.225 DEBUG 20868 --- [nio-8762-exec-1] c.p.cloud.dao.PDao.query : ==> Preparing: SELECT * FROM T where id = ?2017-11-10 13:39:24.259 DEBUG 20868 --- [nio-8762-exec-1] c.p.cloud.dao.PDao.query : ==> Parameters: 1(String) 2017-11-10 13:39:24.320 DEBUG 20868 --- [nio-8762-exec-1] c.p.cloud.dao.PDao.query : <== Total: 1 2017-11-10 13:39:24.321 DEBUG 20868 --- [nio-8762-exec-1] c.p.cloud.dao.PDao.update : ==> Preparing: update T SET info = ? where id = ?2017-11-10 13:39:24.322 DEBUG 20868 --- [nio-8762-exec-1] c.p.cloud.dao.PDao.update : ==> Parameters: 你好!!!(String) 2017-11-10 13:39:24.388 DEBUG 20868 --- [nio-8762-exec-1] c.p.cloud.dao.PDao.update : <== Updates: 1