Spring Boot – Enable SQL logging

Enable sql logging, format and show bind parameters values, add to application.properties:

# spring.jpa.show-sql=true

# Show SQL
spring.jpa.properties.hibernate.show_sql = true

# Format SQL
spring.jpa.properties.hibernate.format_sql=true

# Show bind values!
logging.level.org.hibernate.type.descriptor.sql=trace

Example output (insert):

Hibernate: 
    call next value for hibernate_sequence
Hibernate: 
    insert 
    into
        book
        (isbn, publisher, title, id) 
    values
        (?, ?, ?, ?)
2022-05-17 19:57:10.916 TRACE 44505 --- [           main] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [VARCHAR] - [1234]
2022-05-17 19:57:10.916 TRACE 44505 --- [           main] o.h.type.descriptor.sql.BasicBinder      : binding parameter [2] as [VARCHAR] - [RandomHouse]
2022-05-17 19:57:10.916 TRACE 44505 --- [           main] o.h.type.descriptor.sql.BasicBinder      : binding parameter [3] as [VARCHAR] - [Domain Driven Design]
2022-05-17 19:57:10.917 TRACE 44505 --- [           main] o.h.type.descriptor.sql.BasicBinder      : binding parameter [4] as [BIGINT] - [1]