How To
ForgeRock Identity Platform
Does not apply to Identity Cloud

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

Last updated Apr 13, 2021

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 and earlier 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 and earlier)

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

You should ensure there is enough disk space for the GC logs; if not, you should enable GC log rotation as well by including the following options when you enable GC logging: 

-XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=n -XX:GCLogFileSize=n

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 (All versions)?

How do I collect JVM data for troubleshooting AM (All versions)?

FAQ: AM performance and tuning

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

Maintenance Guide › Tuning JVM Settings

Related Training

N/A

Related Issue Tracker IDs

N/A


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