Pivotal Knowledge Base

Follow

Enabling garbage collection logging with Tomcat on a Linux/UNIX platform (2009621)

Enabling garbage collection logging with Tomcat on a Linux/UNIX platform (2009621)

Purpose

This article provides information on how to enable garbage collection logging with Apache Tomcat or Pivotal tc Server Runtime on a Linux or UNIX platform. In all these cases, you need to add options to the Java executable, but the method is different for each product. The same method can be used for specifying other options for Java.

Resolution

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:
  1. Create a file named setenv.sh in the $TOMCAT_HOME/bin directory.
  2. 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.

  3. Restart Apache Tomcat to enable the changes.

Pivotal tc Server Runtime

To enable garbage collection logging under tc Server:
  1. Open the bin/setenv.sh script for an instance of the runtime using a text editor.
  2. Locate the JVM_OPTS variable.
  3. To enable garbage collection logging, modify and add:

    JVM_OPTS="-XX:+PrintGCTimeStamps \
    -XX:+PrintGCDetails \
    -XX:+PrintGCApplicationStoppedTime \
    -XX:+PrintGCApplicationConcurrentTime \
    -XX:+PrintHeapAtGC \
    -Xloggc:logs/gc.log"

  4. Restart the runtime instance for the changes to take effect.

 

 
©Pivotal 2013

Comments

Powered by Zendesk