Search code examples
javaspringspring-boothibernatejpa

How to log SQL parameters binding in JPA queries with Spring Boot 3?


I would like to log the SQL parameters binding in JPA queries and found the following configuration worked fine for Spring Boot 2.7.3:

# Show all queries
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
#Show SQL parameters binding
logging.level.org.hibernate.sql=debug
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=trace

I use H2 in-memory database and I am experimenting to write some query using JPA EntityManager.

When I try to upgrade my project to Spring Boot 3.0.0-RC1 I continue to see the SQL queries but the parameters binding is no more shown.

I tried some different configurations for hibernate and application logging levels but didn't succeed in finding a working configuration.

What is the correct way to log SQL bindings with Spring Boot 3?


Solution

  • try this:

    logging.level.org.hibernate.orm.jdbc.bind=trace
    logging.level.org.hibernate.type=trace
    logging.level.org.hibernate.stat=debug
    

    it works for me while using Springboot 3.0.0