Skip to content

JdbcTemplate parameter and result logging [SPR-9405] #14041

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: dataIssues in data modules (jdbc, orm, oxm, tx)status: duplicateA duplicate of another issuetype: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions