DEV Community

özkan pakdil
özkan pakdil

Posted on • Originally published at ozkanpakdil.github.io on

Printing running sqls in logs with spring boot 3 and hibernate 6

In application.properties

logging.level.org.hibernate=info
logging.level.org.hibernate.SQL=debug
logging.level.org.hibernate.orm.jdbc.bind=trace
logging.level.org.hibernate.stat=debug
logging.level.org.hibernate.SQL_SLOW=info
logging.level.org.hibernate.cache=debug

Enter fullscreen mode Exit fullscreen mode

will make print all sqls and bindings with it like below

2023-04-08T09:31:54.232+01:00 DEBUG 164224 --- [main] org.hibernate.SQL : insert into "address" ("city", "line1", "post_code", "id") values (?, ?, ?, ?)
2023-04-08T09:31:54.232+01:00 TRACE 164224 --- [main] org.hibernate.orm.jdbc.bind : binding parameter [1] as [VARCHAR] - [Glasgow]
2023-04-08T09:31:54.232+01:00 TRACE 164224 --- [main] org.hibernate.orm.jdbc.bind : binding parameter [2] as [VARCHAR] - [apt:0]
2023-04-08T09:31:54.232+01:00 TRACE 164224 --- [main] org.hibernate.orm.jdbc.bind : binding parameter [3] as [VARCHAR] - [G0]
2023-04-08T09:31:54.232+01:00 TRACE 164224 --- [main] org.hibernate.orm.jdbc.bind : binding parameter [4] as [BIGINT] - [28]

Enter fullscreen mode Exit fullscreen mode

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more