View RSS Feed

My Java Tips

Hibernate logging

Rate this Entry
by , 05-21-2011 at 10:36 PM (2942 Views)
Hibernate logs various events using Apache commons-logging. Hibernate logs are very interesting to read if you want to do some troubleshooting or performance improvement. Hibernate uses commons-logging service for logging. It actually sends the log to either Log4j or to JDK1.4 logging.

If you want hibernate to log using Log4j, then put log4j.jar into class path along with log4j.properties. Since log4j has almost become a standard these days, I would advice using that.
Hibernate defines following log categories.:

  • org.hibernate.SQL Log all SQL DML statements as they are executed
  • org.hibernate.type Log all JDBC parameters
  • org.hibernate.tool.hbm2ddl Log all SQL DDL statements as they are executed org.hibernate.pretty Log the state of all entities (max 20 entities) associated with the session at flush time
  • org.hibernate.cache Log all second-level cache activity
  • org.hibernate.transaction Log transaction related activity
  • org.hibernate.jdbc Log all JDBC resource acquisition
  • org.hibernate.hql.ast.AST Log HQL and SQL ASTs during query parsing
  • org.hibernate.secure Log all JAAS authorization requests
  • org.hibernate Log everything (a lot of information, but very useful for troubleshooting)


Use the one that is required.

Submit "Hibernate logging" to Facebook Submit "Hibernate logging" to Digg Submit "Hibernate logging" to del.icio.us Submit "Hibernate logging" to StumbleUpon Submit "Hibernate logging" to Google

Tags: hql, jdbc, log4j, logging, sql Add / Edit Tags
Categories
Hibernate

Comments