Enabling Detailed SQL Logging
If you have a database problem and need support assistance, it's a good idea to temporarily enable detailed SQL logging before sending us the log files. This will assist us in determining what SQL queries were running during the reported problem. After you've enabled hibernate logging, replicate the action that you suspect is causing the error. This is the best way to ensure that the Confluence log file contains relevant SQL logging.
Log SQL queries with parameters
To enable temporary SQL logging:
- Go to Administration menu , then General Configuration. > Logging and Profiling.
- Choose Enable SQL Logging.
This logging level will persist until you choose Disable SQL Logging or Confluence is restarted. If you need the logging levels to persist (useful for troubleshooting startup problems related to your database, for example) follow the steps below to modify log4j.properties
.
To enable persistent SQL logging:
Use this method if you're using Confluence 5.9.10 or earlier to ensure that parameters are also logged. You can revert the changes once you're done troubleshooting.
- Stop Confluence.
Edit
<install-directory>\confluence\WEB-INF\classes\log4j.properties
Change the following lines from
ERROR
toDEBUG
:## 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.org.hibernate.SQL=debug
Uncomment the following lines:
## 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.org.hibernate.type=trace
Change the following lines from
DEBUG
toTRACE:
log4j.appender.confluencelog.Threshold=TRACE
- Start Confluence.
This logging level will persist, even when Confluence is restarted. As SQL logging is very verbose, you should revert your changes to log4j.properties
once you no longer need the additional info.
Note: For SQL Logging of AO Tables, insert this class with DEBUG Level: