Enable SQL query logging in Jira Data Center
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Purpose
This KB article instructs how to enable detailed SQL logging inside of JIRA. This can be used for:
- Troubleshooting SQL problems with the database.
- Reverse-engineering GUI actions to determine what SQL is submitted for certain user actions.
This is broken down into two sections, OfBiz and Active Objects. They are both persistence ORM frameworks which means they're libraries that can be used to manage the SQL sent to different database systems.
- OfBiz: Used by standard Jira functionality.
- Active Objects: Used by plugins, both third-party and bundled. Active Objects tables can be identified as they're named
AO_<code>_TABLENAME
.
It's important to note enabling SQL logging on production instances may cause a performance degradation on Jira, impacting the ability of end-users to conduct their work.
When possible, work on a lower environment or outside business hours to minimize impact on end-users. If that's not possible, you may consider enabling DEBUG level logs instead of TRACE to reduce the amount of logs generated and also slow down how often these logs will rotate.
Environment
Jira Server/Data Center on any version from Jira 8.0.0.
Solution
To temporarily enable SQL logging
- Log into Jira as a System Administrator.
Go to Administration > System > Logging and Profiling.
OfBiz:
Enable SQL logging below:
The resulting logs will be in
<JIRA HOME>/log/atlassian-jira-sql.log
.
Active Objects:
Search for net.java.ao.sql and set it to
TRACE
:- In the logging page, click at the Configure option as shown below. Add the package com.querydsl.sql and set it to TRACE:
The resulting logs will be in
<JIRA HOME>/log/atlassian-jira.log
.
These settings will be lost on restart, as they're stored in memory.
To permanently enable SQL logging
Solution For Jira versions below 9.5.0
To have Jira persist the DEBUG settings, they need to be changed in the log4j.properties
file as below:
Look for the line below, ands change
OFF
toON
:log4j.logger.com.atlassian.jira.ofbiz.LoggingSQLInterceptor = OFF, sqllog
For the Active Object java.ao.sql, look for the lines below and set
WARN
toTRACE:
log4j.logger.net.java.ao.sql = WARN, console, filelog
For the Active Object com.querydsl.sql, append the following lines at the end of the file:
log4j.logger.com.querydsl.sql = TRACE, console, sqllog log4j.additivity.com.querydsl.sql = false
Solution For Jira versions from 9.5.0
As mentioned in the Jira 9.5.0 Release notes, Log4j was upgraded to the version 2.17.2, which means that, to enable DEBUG packages permanently, a different file needs to be modified.
To have Jira persist the DEBUG settings, they need to be changed in the log4j2.xml
file as below:
Look for the line below, ands change
OFF
toON
:<Logger name="com.atlassian.jira.ofbiz.LoggingSQLInterceptor" level="OFF" additivity="false"> <AppenderRef ref="sqllog"/> </Logger>
For the Active Object java.ao.sql, look for the lines below and set
WARN
toTRACE:
<Logger name="net.java.ao.sql" level="WARN" additivity="false"> <AppenderRef ref="filelog"/> </Logger>
- For the Active Object com.querydsl.sql, append the following lines at the end of the file:
<Logger name="com.querydsl.sql" level="TRACE" additivity="false"> <AppenderRef ref="sqllog"/> </Logger>