For each product, the example in this article assumes that the GC log should go (as specified using
-Xloggc) to the same standard location as other logs. Several recommended parameters are given in the examples. You may need to adjust the examples according to your requirement.
Apache Tomcat
To enable garbage collection logging with Apache Tomcat:
- Create a setenv.sh file in the $TOMCAT_HOME/bin directory.
- Add these entries to the file:
export CATALINA_OPTS=" \
-XX:+PrintGCTimeStamps \
-XX:+PrintGCDetails \
-XX:+PrintGCApplicationStoppedTime \
-XX:+PrintGCApplicationConcurrentTime \
-XX:+PrintHeapAtGC \
-Xloggc:logs/gc.log"
Note: If the setenv.sh already exists, you need to merge these entries to the existing options.
This script is executed when Apache Tomcat is started and sets the JVM options needed to enable garbage collection logging.
- Restart Apache Tomcat to enable the changes.
vFabric ERS Tomcat
To enable garbage collection logging on ERS Tomcat:
- Open the bin/tomcat_startup.sh script using a text editor.
- Locate the line in the script that specifies jvm_options. For example:
jvm_options="-server -Xmx256m"
- Modify this line by adding the new GC parameters to the end of the existing ones, ensuring that everything is in a single line:
jvm_options="-server -Xmx256m -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -XX:+PrintHeapAtGC -Xloggc:logs/gc.log"
- Restart the ERS Tomcat instance for the changes to take effect.
vFabric tc Server Runtime
To enable garbage collection logging under tc Server:
- Open the bin/setenv.sh script file for an instance of the runtime using a text editor.
- Locate the SUN_JVM_OPTS variable. By default, this variable is commented.
- To enable garbage collection logging, un-comment the variable and modify it as:
SUN_JVM_OPTS="-XX:+PrintGCTimeStamps \
-XX:+PrintGCDetails \
-XX:+PrintGCApplicationStoppedTime \
-XX:+PrintGCApplicationConcurrentTime \
-XX:+PrintHeapAtGC \
-Xloggc:logs/gc.log"
- Restart the runtime instance for the changes to take effect.