Wednesday, June 27, 2007

Hibernate Logging

Have you ever tried to get hibernate to log SQL? It's quite easy, just set log4j.logger.org.hibernate.SQL=DEBUG, and hey presto, you have SQL statements logged. Except it's not too useful, as most of them are parameterised queries, with lists of question marks instead of values. So you do a search on Google and it turns up millions of entries saying you need to set log4j.logger.org.hibernate.type. But it doesn't help, because all the articles say the value should be INFO, whereas what you really want is log4j.logger.org.hibernate.type=TRACE.

So there you go. Maybe Google will turn up my blog entry instead for you.