Enable SQL query logging in Bitbucket Data Center

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs 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

Summary

For troubleshooting purposes, it may be necessary to enable SQL query and parameter logging to review the queries that Bitbucket runs.

This article describes procedures for enabling them.

Solution

Bitbucket versions >= 5.0

During Runtime

Enabling SQL query logging at runtime

This method enables the debug log level for SQL queries at runtime, without the need of restarting Bitbucket Server. More details are provided on the Enable debug logging page.

Enable debug log level

1 curl -X PUT -u <ADMIN_USERNAME> <BASE_URL>/rest/api/latest/logs/logger/org.hibernate.SQL/debug

Use the following to disable the debug log level by setting it back to warn:

Set log level to warn

1 curl -X PUT -u <ADMIN_USERNAME> <BASE_URL>/rest/api/latest/logs/logger/org.hibernate.SQL/warn

Enabling SQL parameter logging at runtime

This may log sensitive information (user names, group names, project names, etc).

This method enables the trace log level for logging the query parameters at runtime, without the need of restarting Bitbucket Server. More details are provided on the Enable debug logging page.

Enable trace log level

1 curl -X PUT -u <ADMIN_USERNAME> <BASE_URL>/rest/api/latest/logs/logger/org.hibernate.type/trace

Use the following to disable the trace log level by setting it back to warn:

Set log level to warn

1 curl -X PUT -u <ADMIN_USERNAME> <BASE_URL>/rest/api/latest/logs/logger/org.hibernate.type/warn

At Startup

Enabling SQL query logging at startup

Add the following to the $BITBUCKET_HOME/shared/bitbucket.properties file followed by a restart.

1 logging.logger.org.hibernate.SQL=debug

To disable, just remove the line followed by a restart.

Enabling SQL parameter logging at startup

This may log sensitive information (user names, group names, project names, etc).

Add the following to the $BITBUCKET_HOME/shared/bitbucket.properties file followed by a restart.

1 logging.logger.org.hibernate.type=trace

To disable, just remote the line followed by a restart.

Bitbucket versions < 5.0

Use the following procedures for versions earlier than 5.0:

Enabling SQL query logging on startup

  1. Create a file <BITBUCKET_HOME>/logback.xml with the following text in it:

    1 2 3 <included> <logger name="org.hibernate.SQL" level="DEBUG"/> </included>
  2. Restart your Bitbucket Server instance.

  3. Look for org.hibernate.SQL logging lines in <BITBUCKET_HOME>/log/atlassian-bitbucket.log such as:

    1 2 3 4 2014-12-04 19:39:39,749 DEBUG [clusterScheduler_Worker-8] org.hibernate.SQL delete sta_activity_0 from sta_activity sta_activity_0 inner join HT_sta_pr_rescope_activity HT_sta_pr_rescope_activity_0 on sta_activity_0.id=HT_sta_pr_rescope_activity_0.activity_id

Enabling parameter logging

This may log sensitive information (user names, group names, project names, etc).

SQL queries are parameterized with ?. If you need to see the parameter data, you can enable parameter logging by changing the logback.xml file as below.

1 2 3 4 <included> <logger name="org.hibernate.SQL" level="DEBUG"/> <logger name="org.hibernate.type" level="TRACE"/> </included>

Updated on March 17, 2025

Still need help?

The Atlassian Community is here for you.