This page last changed on Dec 12, 2007 by smaddox.

Confluence uses the open source persistence framework Hibernate. This page tells you how to configure Confluence's logging to report individual SQL requests being sent to the database by Hibernate. It is useful for troubleshooting:

  • XML site backups that fail to import
  • Exceptions caused by an illegal database operation

You can also enable SQL logging at runtime via the Administration Console. This option does not allow you to enable logging of SQL parameter values.

To enable detailed SQL logging in Confluence, you need to modify log4j.properties, located in confluence/WEB-INF/classes.

If you require support assistance with a database related problem, it is advisable to enable detailed SQL logging prior sending us the log files. It will assists us determining what SQL queries were running during the reported problem.

If the entries mentioned below are not defined in the log4j.properties file, you can manually add the entries to the file in the 'Hibernate Logging' section.

To log SQL queries

Stop Confluence, then uncomment the following lines in log4j.properties:

## log hibernate prepared statements/SQL queries (equivalent to setting 'hibernate.show_sql' to 'true')
log4j.logger.net.sf.hibernate.SQL=DEBUG, confluencelog
log4j.additivity.net.sf.hibernate.SQL=false

To log SQL queries with parameters

Stop Confluence, then uncomment the following lines in log4j.properties:

## log hibernate prepared statement parameter values
log4j.logger.net.sf.hibernate.type=DEBUG, confluencelog
log4j.additivity.net.sf.hibernate.type=false

To disable batched updates (for simpler debugging)

Stop Confluence, then edit databaseSubsystemContext.xml:

  • In Confluence 2.5.x and earlier, the databaseSubsystemContext.xml file is at confluence/WEB-INF/classes/databaseSubsystemContext.xml
  • From Confluence 2.6.x, the databaseSubsystemContext.xml file is available in the confluence-2.6.0.jar file located in the <confluence-install>/WEB-INF/lib directory.

Uncomment the <prop> line in the following location:

<!-- it can be useful to disable batching during debugging, as HSQLDB doesn't report the exact statement which fails in batch mode -->
<prop key="hibernate.jdbc.batch_size">0</prop>

Related Topic

Troubleshooting SQL exceptions
Working with Confluence Logs

Document generated by Confluence on Dec 20, 2007 19:04