How to Enable Garbage Collection (GC) Logging on Bitbucket

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

Garbage collection logs are useful when trying to isolate issues within Java-based applications as they will pinpoint blocked, hung or stuck threads that may be causing downstream effects in the application. It is always useful to collect at least 10 minutes of garbage collection logs, but analysis accuracy is often increased by the amount of recent log data to review.

Solution

For Linux

Add the following parameters in the $BITBUCKET_HOME/bin/_start-webapp.sh file:

ℹ️ If you existing value assigned for JVM_SUPPORT_RECOMMENDED_ARGS, please append the values.

  • For Java 17 and above:

    1 JVM_SUPPORT_RECOMMENDED_ARGS="-Xloggc:$BITBUCKET_HOME/log/`date +%F_%H-%M-%S`-gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCCause -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=5M"
  • For Java 11:

    1 JVM_SUPPORT_RECOMMENDED_ARGS="-Xlog:gc*:file=$BITBUCKET_HOME/log/gc-%t.log:tags,time,uptime,level:filecount=10,filesize=5M"
  • For Java 8:

    1 JVM_SUPPORT_RECOMMENDED_ARGS="-Xloggc:$BITBUCKET_HOME/log/gc-%t.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintGCCause -XX:+UseG1GC -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=20M"
Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.