views:

528

answers:

1

I'm using Hibernate's EntityManager as a JPA implementation. What I want is logging of the query (HQL or JPA Query Language) made to EntityManager. This is different than SQL logging (which is enabled with the hibernate.show_sql property).

My application issues several queries to Hibernate. I want logging of both the queries issued to Hibernate and the corresponding generated SQL queries. I'd like to achieve this without having to add my own logging just before querying Hibernate.

Does Hibernate support this?

+1  A: 

These are the published logging categories for Hibernate:

http://docs.jboss.org/hibernate/stable/core/reference/en/html/configuration-logging.html

It's not clear which os these would handle HQL logging, so I suggest turning on INFO logging for org.hibernate (i.e. everything), find out which logger does HQL logging, then only use that logger.

skaffman