dsestero
dsestero

Reputation: 63

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?

Upvotes: 6

Views: 13442

Answers (2)

Mayank modi
Mayank modi

Reputation: 21

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

Upvotes: 2

dannyxu
dannyxu

Reputation: 571

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

Upvotes: 20

Related Questions