J'ai fait une feuille de triche qui, je pense, peut être utile aux autres. Dans tous les exemples, vous pouvez supprimer la format_sql
propriété si vous souhaitez conserver les requêtes enregistrées sur une seule ligne (pas de jolie impression).
Jolies requêtes SQL d'impression à standard sans paramètres d'instructions préparées et sans optimisations d'un framework de journalisation :
application.properties
fichier:
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
application.yml
fichier:
spring:
jpa:
show-sql: true
properties:
hibernate:
format_sql: true
Jolies requêtes SQL d'impression avec des paramètres d'instructions préparées à l'aide d'un cadre de journalisation :
application.properties
fichier:
spring.jpa.properties.hibernate.format_sql=true
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
application.yml
fichier:
spring:
jpa:
properties:
hibernate:
format_sql: true
logging:
level:
org:
hibernate:
SQL: DEBUG
type:
descriptor:
sql:
BasicBinder: TRACE
Jolies requêtes SQL d'impression sans paramètres d'instructions préparées à l'aide d'un cadre de journalisation :
application.properties
fichier:
spring.jpa.properties.hibernate.format_sql=true
logging.level.org.hibernate.SQL=DEBUG
application.yml
fichier:
spring:
jpa:
properties:
hibernate:
format_sql: true
logging:
level:
org:
hibernate:
SQL: DEBUG
Source (et plus de détails): https://www.baeldung.com/sql-logging-spring-boot