How To
ForgeRock Identity Platform
Does not apply to Identity Cloud

How do I enable Garbage Collector (GC) Logging for AM?

Last updated Jan 16, 2023

The purpose of this article is to provide information on enabling GC Logging for AM. It assumes you already have a working AM server installed.


1 reader recommends this article

Overview

Unified JVM Logging is used for GC logging in Java® 11. The logging options available in Java 8 will not work with Java 11. See JEP 158: Unified JVM Logging for further information.

This article provides details on enabling GC logging according to which version of Java you are using:

You can use the Universal GC Log Analyzer to analyze your GC log. This is a third-party website that we suggest can be used for analysis but is not supported by ForgeRock.

Enabling GC Logging (Java 11)

The information given here is specific to the Apache Tomcat™ web container; you should make similar changes in the configuration file specific to your web container if you use a different one.

On Unix® and Linux® systems:

​You should enable GC logging by specifying CATALINA_OPTS settings in the setenv.sh file (typically located in the /tomcat/bin/ directory). If this file doesn't exist, you should create it in the same directory as the catalina.sh file (also typically located in the /tomcat/bin/ directory).

To enable GC logging:

  1. Add a line similar to the following to the setenv.sh file: export CATALINA_OPTS="$CATALINA_OPTS -Xlog:gc=debug:file=/tmp/gc.log:time,uptime,level,tags:filecount=5,filesize=100m"There are many options available as detailed in JEP 158: Unified JVM Logging but this is a good starting point.
  2. Restart the web container.

Once the web container has successfully restarted, there should be a GC log file located in the directory specified in the file: option.

On Microsoft® Windows® systems:

​You should enable GC logging by specifying CATALINA_OPTS settings in the setenv.bat file (typically located in the \tomcat\bin\ directory). If this file doesn't exist, you should create it in the same directory as the catalina.bat file (also typically located in the \tomcat\bin\ directory).

To enable GC logging:

  1. Add the following line to the setenv.bat file: set CATALINA_OPTS=-Xlog:gc=debug:file=C:\tmp\gc.log:time,uptime,level,tags:filecount=5,filesize=100mThere are many options available as detailed in JEP 158: Unified JVM Logging but this is a good starting point.
  2. Restart the web container.

Once the web container has successfully restarted, there should be a GC log file located in the directory specified in the file: option.

Enabling GC Logging (Java 8)

The information given here is specific to the Tomcat web container; you should make similar changes in the configuration file specific to your web container if you use a different one.

Note

GC logs will be overwritten when the server restarts unless you have implemented a log rotation strategy; log rotation is also important for managing disk space. You can enable GC log rotation by including the following options when you enable GC logging: -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=n -XX:GCLogFileSize=nHowever, using these options can lead to situations where rotated files end up in an unexpected order; see Rotating GC Log Files for further information and alternatives.

On Unix and Linux systems:

​You should enable GC logging by specifying CATALINA_OPTS settings in the setenv.sh file (typically located in the /tomcat/bin/ directory). If this file doesn't exist, you should create it in the same directory as the catalina.sh file (also typically located in the /tomcat/bin/ directory).

To enable GC logging:

  1. Add the following line to the setenv.sh file: export CATALINA_OPTS="$CATALINA_OPTS -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintGCCause -Xloggc:[filename]"replacing [filename] with the path to the file that you would like to create to store the log file.
  2. Restart the web container.

Once the web container has successfully restarted, there should be a GC log file located in the directory specified in the -Xloggc: option.

On Microsoft Windows systems:

​You should enable GC logging by specifying CATALINA_OPTS settings in the setenv.bat file (typically located in the \tomcat\bin\ directory). If this file doesn't exist, you should create it in the same directory as the catalina.bat file (also typically located in the \tomcat\bin\ directory).

To enable GC logging:

  1. Add the following line to the setenv.bat file: set CATALINA_OPTS=-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintGCCause -Xloggc:[filename]replacing [filename] with the path to the file that you would like to create to store the log file.
  2. Restart the web container.

Once the web container has successfully restarted, there should be a GC log file located in the directory specified in the -Xloggc: option.

See Also

Best practice for JVM Tuning with G1 GC

Best practice for JVM Tuning with CMS GC

How do I change the JVM heap size for AM?

How do I collect JVM data for troubleshooting AM?

FAQ: AM performance and tuning

How do I diagnose a hung AM (All versions) server?

Tune JVM settings


Copyright and Trademarks Copyright © 2023 ForgeRock, all rights reserved.