How to Enable Garbage Collection (GC) Logging on Bitbucket

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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

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:
(info) If you existing value assigned for JVM_SUPPORT_RECOMMENDED_ARGS, please append the values.

  • For Java 17 and above:

    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: 

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

    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"
Description

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.

ProductConfluence, Bitbucket, Jira, Bamboo
Last modified on Oct 18, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.