Log queries with parameters in Hibernate 5 and 6

For debugging purposes it is often useful to log hibernate generated queries in your application.

In a Spring Boot application up to 2.7 using Hibernate 5.x, this can be achieved using the following configuration.

# log SQL statements
logging.level.org.hibernate.SQL=debug
# log SQL binding parameters to get the actual values of a query parameter
logging.level.org.hibernate.type.descriptor.sql=trace

In Hibernate 6.x used e.g. in Spring Boot 3.0 / 3.1 the parameter for the parameter output has changed. In order to acchive the same result as above, the following configuration is required.

# log SQL statements
logging.level.org.hibernate.SQL=debug
# log SQL binding parameters to get the actual values of a query parameter
logging.level.org.hibernate.orm.jdbc.bind=trace

In summary: for parameter logging up to Hibernate 5 you have to configure “org.hibernate.type.descriptor.sql” and for Hibernate 6 you have to use “org.hibernate.orm.jdbc.bind”