How to Enable Garbage Collection (GC) Logging
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
Server* 製品のサポートは 2024 年 2 月 15 日をもって終了します。Server 製品を利用している場合は、Atlassian Server のサポート終了のお知らせページにて移行オプションをご確認ください。
*Fisheye および Crucible は除く
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
Server* 製品のサポートは 2024 年 2 月 15 日をもって終了します。Server 製品を利用している場合は、Atlassian Server のサポート終了のお知らせページにて移行オプションをご確認ください。
*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-home> directory)
-Xloggc:<confluence-home>/logs/`date +%F_%H-%M-%S`-gc.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.
Windows の場合
Batch file
If you start Confluence using 'start-confluence.bat', add the below code to setenv.bat
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
NB: 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-home> directory)
-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
Note - When using Java 11
Java 11 では、Java 8 で使用されていたガベージ コレクション ロギングに使用されるものを含む一部の JVM フラグが削除されています。
これらが setenv.sh または setenv.bat で指定されている JVM フラグにまだ含まれていると、JVM を起動できません。
次のオプションは Java 11 では認識されないことがわかっています。
- -d64
- PrintGCTimeStamps
- PrintGCDateStamps
- PrintTenuringDistribution
- PrintGCCause
- PrintGCDetails
- UseGCLogFileRotation
- NumberOfGCLogFiles
- GCLogFileSize
Java 11 では、これらの GClog オプションは Xlog で処理されるようになりました。変換テーブルは以下を参照してください。
Please refer to the Knowledge Article below in case JVM is not able to start and Error Unrecognized VM option 'UseGCLogFileRotation' is seen