Confluence uses the open source persistence framework Hibernate. This page tells you how to configure Confluence's logging to report individual SQL requests that are sent to the database by Hibernate. It is useful for troubleshooting the following events:
- XML site backups that fail to import.
- Exceptions caused by an illegal database operation.
To enable detailed SQL logging in Confluence, you need to modify log4j.properties
, located in confluence/WEB-INF/classes
.
After you have enabled hibernate logging, please replicate the action that is causing the error in the first place. This is the best way to ensure that the Confluence log file contains relevant SQL logging.
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 change the following lines in log4j.properties
from ERROR
to DEBUG
:
## log hibernate prepared statements/SQL queries (equivalent to setting 'hibernate.show_sql' to 'true') ## DEBUG, TRACE or ALL is required to see query strings log4j.logger.net.sf.hibernate.SQL=DEBUG
To Log SQL Queries with Parameters
- Stop Confluence
Uncomment the following lines in
log4j.properties
:## log hibernate prepared statement parameter values. Note: due to caching in net.sf.hibernate.type.NullableType, requires restart to take effect ## TRACE or ALL is required to see parameter values ## Note that log4j.appender.confluencelog.Threshold (or other appenders) also must be TRACE or ALL to see any trace messages in the logs log4j.logger.net.sf.hibernate.type=TRACE
Change the following lines in
log4j.properties
fromDEBUG
toTRACE:
log4j.appender.confluencelog.Threshold=TRACE
- Restart Confluence
This needs to be done along with the changes to log SQL queries above (whether by the UI or by modifying the properties file).
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 atconfluence/WEB-INF/classes/databaseSubsystemContext.xml
- From Confluence 2.6.x, the
databaseSubsystemContext.xml
file is available in theconfluence-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>