How to log SQL statements in Spring Boot? How to log SQL statements in Spring Boot? java java

How to log SQL statements in Spring Boot?


try using this in your properties file:

logging.level.org.hibernate.SQL=DEBUGlogging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE


This works for stdout too:

spring.jpa.properties.hibernate.show_sql=truespring.jpa.properties.hibernate.use_sql_comments=truespring.jpa.properties.hibernate.format_sql=true

To log values:

logging.level.org.hibernate.type=trace

Just add this to application.properties.


This works for me (YAML):

spring:  jpa:    properties:      hibernate:        show_sql: true        format_sql: truelogging:  level:    org:      hibernate:        type: trace