How To
ForgeRock Identity Platform
ForgeRock Identity Cloud

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

Last updated Jun 8, 2021

The purpose of this article is to provide information on enabling GC Logging for IG when it is running in a web container. It assumes you already have a working IG 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:

IG 7  and later include a standalone Java executable file that runs in a Container-less execution environment. To enable GC logging for IG in Standalone Mode, please see Configure Environment Variables and System Properties for further information.

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

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

How do I use the msnapshots script to capture information for troubleshooting IG (All versions)?

Tuning IG's JVM

Related Training

N/A

Related Issue Tracker IDs

N/A


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