How do I enable Garbage Collector (GC) Logging for DS?
The purpose of this article is to provide information on enabling GC Logging for DS. It assumes you already have a working DS server installed.
2 readers recommend 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)
On Unix® and Linux® systems:
You can enable GC logging as follows:
- Locate and edit your /path/to/ds/config/java.properties file for the DS instance for which you want to enable GC Logging.
- Append the required options to the entry start-ds.java-args=. For example: start-ds.java-args=-server -Xlog:gc=debug:file=/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.
- Restart the DS server.
Once the server has successfully restarted, there should be a GC log file located in the directory specified in the file:
option.
On Microsoft® Windows® systems:
You can enable GC logging as follows:
- Locate and edit your \path\to\ds\config\java.properties file for the DS instance for which you want to enable GC Logging.
- Append the required options to the entry start-ds.java-args=. For example: start-ds.java-args=-server -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.
- Restart the DS server.
Once the server has successfully restarted, there should be a GC log file located in the directory specified in the file:
option.
Enabling GC Logging (Java 8)
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 can enable GC logging as follows:
- Locate and edit your /path/to/ds/config/java.properties file for the DS instance for which you want to enable GC Logging.
- Append the following options to the entry start-ds.java-args= -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. For example: start-ds.java-args=-server -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintGCCause -Xloggc:/tmp/gc.log
- Restart the DS server.
Once the server has successfully restarted, there should be a GC log file located in the directory specified in the -Xloggc:
option.
On Microsoft Windows systems:
You can enable GC logging as follows:
- Locate and edit your \path\to\ds\config\java.properties file for the DS instance for which you want to enable GC Logging.
- Append the following options to the entry start-ds.java-args= -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. For example: start-ds.java-args=-server -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintGCCause -Xloggc:C:\tmp\gc.log
- Restart the DS server.
Once the server 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 tune DS process sizes: JVM heap and database cache?
How do I collect JVM data for troubleshooting DS?