Description
David Thexton opened SPR-9405 and commented
I noted when trying to diagnose BATCH-1852 (which was making use of JdbcTemplate) that there were no options to enable logging JDBC query parameters or query results. I recalled this was possible for Hibernate (see http://www.seamframework.org/Documentation/EnablingJDBCBindParameterLoggingWithHibernateAndLog4j) and wanted the same feature for Spring JdbcTemplate. I could have used P6Spy (see http://sourceforge.net/projects/p6spy/), although that approach seemed inconvenient.
As this logging can be very verbose I used separate classes (and thus loggers). Continue to set logger "org.springframework.jdbc.core.JdbcTemplate" to debug to see the queries being executed and simple results. Additionally set logger "org.springframework.jdbc.core.PreparedStatementValueLogger" to debug for query parameter logging and logger "org.springframework.jdbc.core.PreparedStatementResultLogger" to debug for further query result logging.
I've implemented the change in a style that will hopefully be seen to fit and I'll issue a pull request as soon as I've completed testing and committed to my spring-framework fork. I'm happy to make further changes for this issue if necessary. Please let me know.
Affects: 3.2 M1
Issue Links:
- Logging of SQL Params and Query when using JdbcTemplate [SPR-7782] #12438 Logging of SQL Params and Query when using JdbcTemplate ("duplicates")