6

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?

3
  • 4
    maybe logging.level.org.hibernate.orm.jdbc.bind=trace - based on thorben-janssen.com/hibernate-logging-guide/… since boot 3.0.0-RC1 uses Hibernate 6.1.4 Commented Nov 4, 2022 at 19:22
  • I'm using logging.level.net.ttddyy.dsproxy.listener=debug during work on query performance Commented Nov 4, 2022 at 19:53
  • stackoverflow.com/a/37464963/175554 looks like the most spring way Commented Nov 6, 2022 at 21:09

2 Answers 2

19

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

Sign up to request clarification or add additional context in comments.

2 Comments

To me what makes the difference is the line: logging.level.org.hibernate.orm.jdbc.bind=trace
I tried through CLI both --logging and -Dlogging. No output.
2

You can try below, first one will log SQL statements & 2nd one will log the binding parameters.

logging.level.sql=DEBUG
logging.level.org.hibernate.orm.jdbc.bind=TRACE

1 Comment

logging.level.org.hibernate.orm.jdbc.bind=TRACE already appears in the accepted answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.