How to Enable Garbage Collection (GC) Logging

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

 

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

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.

*Fisheye および Crucible は除く

目的

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.

Linux

Add the following parameters into your Confluence System Properties, in the <CONFLUENCE_INSTALL>/bin/setenv.sh  file (be sure to enter the path for your <CONFLUENCE_INSTALL> directory): 

When running Confluence with JDK 8
-Xloggc:<CONFLUENCE_INSTALL>/logs/gc-`date +%F_%H-%M-%S`.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCCause
-XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=5M

The parameter -XX:+PrintGCCause  was introduced within Java 1.7.0_45 and will not work if you are using a version of Java prior to that version. Please check the version of Java that is being used by your instance of Confluence prior to using this flag.

When running Confluence with JDK11/17
-Xlog:gc*:file=<CONFLUENCE_INSTALL>/logs/gc-%t.log:tags,time,uptime,level:filecount=10,filesize=5M

Windows

Batch File

If you start Confluence using start-confluence.bat , add the below code to setenv.bat :

When running Confluence with JDK 8
rem Create a timestamp with date and time, replacing ' ' with '0' and '/' with '-'
set atlassian_timestamp=%DATE:~-4%.%DATE:~4,2%.%DATE:~7,2%_%TIME:~0,2%.%TIME:~3,2%.%TIME:~6,2%
set atlassian_timestamp=%atlassian_timestamp: =0%
set atlassian_timestamp=%atlassian_timestamp:/=-%
set atlassian_logsdir=%~dp0..\logs

set CATALINA_OPTS=%CATALINA_OPTS% -Xloggc:"%ATLASSIAN_LOGSDIR%\gc-%atlassian_timestamp%.log"
set CATALINA_OPTS=%CATALINA_OPTS% -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=5M -XX:+PrintGCCause
set CATALINA_OPTS=%CATALINA_OPTS% -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution 

(warning) This will create the garbage collection logs in the <CONFLUENCE_INSTALL>  directory.

When running Confluence with JDK 11/17
rem Create a timestamp with date and time, replacing ' ' with '0' and '/' with '-'
set atlassian_timestamp=%DATE:~-4%.%DATE:~4,2%.%DATE:~7,2%_%TIME:~0,2%.%TIME:~3,2%.%TIME:~6,2%
set atlassian_timestamp=%atlassian_timestamp: =0%
set atlassian_timestamp=%atlassian_timestamp:/=-%
set atlassian_logsdir=%~dp0..\logs

set CATALINA_OPTS=%CATALINA_OPTS% -Xloggc:"%atlassian_logsdir%\gc-%atlassian_timestamp%.log:tags,time,uptime,level:filecount=10,filesize=5M"

(warning) This will create the garbage collection logs in the <CONFLUENCE_INSTALL>  directory.

Service

If you start Windows as a Service, add the below to the service by following these steps (be sure to enter the path for your <CONFLUENCE_INSTALL> directory)

When running Confluence with JDK 8
-Xloggc:<confluence-home>\logs\gc-%t.log
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+PrintGCTimeStamps
-XX:+PrintGCCause
-XX:+PrintTenuringDistribution
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=10
-XX:GCLogFileSize=5M
When running Confluence with JDK 11/17
-Xloggc:<CONFLUENCE_INSTALL>\logs\gc-%t.log:tags,time,uptime,level:filecount=10,filesize=5M

Differences between JDK 8 and JDK11/17

For further information about the different GC configuration between JDK8 and JDK11/17, please check our KB Unrecognized JVM GC options when using JDK 11/17




最終更新日 2024 年 4 月 26 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.