Skip to content

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

Closed

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:

Activity

  1. spring-projects-issues commented on May 14, 2012

    @spring-projects-issues
    CollaboratorAuthor

    David Thexton commented

    Made pull request (see #78).

  2. spring-projects-issues commented on May 14, 2012

    @spring-projects-issues
    CollaboratorAuthor

    Chris Beams commented

    Thanks, David for the contribution. I'm resolving this particular issue as a duplicate of #12438. Give that issue a read and see what you think. We can continue the conversation there as to design, etc.

  3. spring-projects-issues commented on May 14, 2012

    @spring-projects-issues
    CollaboratorAuthor

    David Thexton commented

    Hi Chris. It's a real shame I didn't see the relevance of StatementCreatorUtils earlier. I'll look more closely and then comment further. Thanks for the quick response.

  4. spring-projects-issues commented on May 21, 2012

    @spring-projects-issues
    CollaboratorAuthor

    David Thexton commented

    I've had a read and commented on #12438. Thanks.

  5. added
    in: data
    type: enhancement
    status: duplicate
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: datastatus: duplicatetype: enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions