Friday, April 10, 2009

Log Hibernate SQL Statements and Parameter Values

It is important to see Hibernate SQL Statements and the binding values for parameters in log to troubleshoot and debug. A nice trick here shows how to do it in log4j.

Basically, it is done by adding the following two lines in log4j.properties.
log4j.category.org.hibernate.SQL=DEBUG
log4j.category.org.hibernate.type=TRACE

You also need to change the appender Threshold, for example, CONSOLE.
log4j.appender.CONSOLE.Threshold=TRACE

No comments:

Post a Comment