I'm developing a web application using the Play Framework with JPA/Hibernate. For debugging purposes, it would be great to see the SQL statements used by JPA. There already is another thread with the same question, but it is about Play 1 and the given solution does not work for me - it seems that jpa.debugSQL=true
cannot be used in Play 2 (No Persistence provider for EntityManager named true).
Instead, I added the following to Play's application.conf:
db.default.logStatements=true
logger.org.hibernate=DEBUG
I'm not sure if I need both lines, but at least the SQL statements are logged now. But for large queries, Hibernate prints a ton of debug messages which make the already printed SQL statements disappear in my console window. I already tried to increase the buffer of the console window, but that didn't change much.
What do I have to do in order to inspect the statements in a comfortable way?
edit:
When setting logger.org.hibernate
to INFO
, I'm not getting any statements at all (even with db.default.logStatements=true
).
Try first with the config
db.default.logStatements=true
logger.org.hibernate=DEBUG
Find out which class logs the statements (for example org.hibernate.xxx.StatementLogger). Change back to INFO for org.hibernate and add a new line for the statement logger package:
logger.org.hibernate=INFO
logger.org.hibernate.xxx=DEBUG
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With