如果你想查看Spring Data JDBC执行的SQL语句,该怎么做呢?由于它使用绑定变量,我还想在日志中看到它们的值。
JdbcTemplate
执行所有SQL语句。因此,您需要为其配置日志记录。
模板本身使用DEBUG
级别记录语句本身。要查看这些内容,您必须将org.springframework.jdbc.core.JdbcTemplate
的日志级别设置为DEBUG
。org.springframework.jdbc.core.StatementCreatorUtils
在TRACE
级别上记录。application.properties
中应该能够解决问题。logging.level.org.springframework.jdbc.core.StatementCreatorUtils=TRACE
logging.level.org.springframework.jdbc.core.JdbcTemplate=DEBUG
logging.level.org.springframework.jdbc.core = TRACE