I recently upgraded my Spring Boot app to v3.0 which required Hibernate to be upgraded to v6.1.5.Final.
I'm using Spring Data JPA with Hibernate as the JPA provider. When I run the app locally, I want to log SQL statements and the values of any parameters in those statements. To this end, I've added the following to my local configuration, as per this blog post:
spring:
jpa:
show-sql: false
properties:
hibernate:
format_sql: true
logging:
level:
org.hibernate.SQL: debug
org.hibernate.type.descriptor.sql: trace
I'm pretty sure this worked prior to the upgrade, but now only the SQL statements are logged i.e. the parameter values are missing.
Is it possible to log the query parameter values when using Spring Boot v3.0 and Hibernate v6.1.5.Final?
CodePudding user response:
Logging SQL in Spring boot 3 with Hibernate 6:
logging.level.sql
for SQL logging group including Hibernate SQL logger.logging.level.org.hibernate.orm.jdbc.bind
for showing the binding parameters
So this should work:
logging:
level:
sql: debug
org.hibernate.orm.jdbc.bind: trace