2

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?

dsestero
  • 21
  • 5
  • 3
    maybe `logging.level.org.hibernate.orm.jdbc.bind=trace` - based on https://thorben-janssen.com/hibernate-logging-guide/#Logback_via_Slf4j_configuration_for_Hibernate_4_5_and_6 since boot 3.0.0-RC1 uses Hibernate 6.1.4 – zapl Nov 04 '22 at 19:22
  • I'm using logging.level.net.ttddyy.dsproxy.listener=debug during work on query performance – notAPPP Nov 04 '22 at 19:53
  • Thanks @zapl but I tried both adding `logging.level.org.hibernate.orm.jdbc.bind=trace` to my configuration without and with removal of `logging.level.org.hibernate.type.descriptor.sql.BasicBinder=trace` but nothing changes – dsestero Nov 04 '22 at 21:24
  • https://stackoverflow.com/a/37464963/175554 looks like the most spring way – ozkanpakdil Nov 06 '22 at 21:09

1 Answers1

5

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

dannyxu
  • 396
  • 2
  • 5