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