Enabling garbage collection logging with Tomcat on Windows platform
search cancel

Enabling garbage collection logging with Tomcat on Windows platform

book

Article ID: 331372

calendar_today

Updated On:

Products

VMware Support Only for Apache Tomcat

Issue/Introduction

This article provides steps to enable garbage collection logging with Apache Tomcat, vFabric ERS Tomcat, or vFabric tc Server Runtime on the Windows platform. In all these cases, you need to add options to the Java executable, but the method may vary for each product. The same method can be used for specifying other Java options.

Environment

Apache Tomcat 5.5
VMware vFabric tc Server 2.1
VMware vFabric tc Server 2.6
Apache Tomcat 6
VMware vFabric Enterprise Ready Server 4
Apache Tomcat 7
VMware vFabric tc Server 2.5
VMware vFabric tc Server 2.0

Resolution

Note: For each product, the example assumes that the GC log should go in the same standard location as other logs. You may need to adjust the examples for your own situation.

Apache Tomcat

To enable garbage collection logging with Apache Tomcat:
  1. Execute the tomcat6w.exe (tomcat5w.exe for Tomcat 5.5.x) application. This displays a configuration for the Apache Tomcat Windows service.
  2. Click the Java tab.
  3. Add the following options to the Java Options section:

    -XX:+PrintGCTimeStamps
    -XX:+PrintGCDetails
    -XX:+PrintGCApplicationStoppedTime
    -XX:+PrintGCApplicationConcurrentTime
    -XX:+PrintHeapAtGC
    -Xloggc:C:\apache\apache-tomcat-6.0.32\logs\gc.log

    Note: You must specify the full path to the log file. In this example, the full path is C:\apache\apache-tomcat-6.0.32\logs\gc.log.

  4. Switch back to the General tab.
  5. Restart the service.

    To restart the service, click Stop and then click Start. Garbage collection logging should now be enabled.

ERS Tomcat

To enable garbage collection logging on ERS Tomcat:
  1. Open the conf/wrapper.properties file for the instance using a text editor.
  2. Navigate to the end of the file and look for the line that starts with wrapper.cmd_line.
  3. In the line before wrapper.cmd_line, add this new line to define where the log should be saved:

    garbage.log=$(server.home)\logs\gc.log

  4. In the line that starts with wrapper.cmd_line, add this parameters between $(wrapper.javabin)and -server:

    -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -XX:+PrintHeapAtGC -Xloggc:${garbage.log}

    The line should now be similar to:

    wrapper.cmd_line="$(wrapper.javabin)" -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -XX:+PrintHeapAtGC -Xloggc:${garbage.log} -server

    Note: Ensure that everything appears in the same line.

  5. To apply the changes, uninstall, install, and then start the service using these commands:
> bin\tomcat_startup.bat uninstall
> bin\tomcat_startup.bat install
> bin\tomcat_startup.bat start

tc Server Runtime

To enable garbage collection logging under tc Server:
  1. Open the conf/wrapper.conf file for an instance of the runtime using a text editor.
  2. Locate the lines that start wrapper.java.additional. These lines are numbered from 1 to X where X is the highest number and the numbers from 1 to X are consecutive. For example:

    wrapper.java.additional.1=-Xmx512m
    wrapper.java.additional.2=-Xss192k
    ...
    wrapper.java.additional.10="-Dwrapper.dump.port=-1"

    Note: The default configuration should run from 1 to 10.

  3. To enable garbage collection logging, add lines which contain the additional properties, making sure to increment the numbers for each line. For example, assuming that the original wrapper.java.addition parameters stop at 10, the additional lines are similar to:

    wrapper.java.additional.11=-XX:+PrintGCTimeStamps
    wrapper.java.additional.12=-XX:+PrintGCDetails
    wrapper.java.additional.13=-XX:+PrintGCApplicationStoppedTime
    wrapper.java.additional.14=-XX:+PrintGCApplicationConcurrentTime
    wrapper.java.additional.15=-XX:+PrintHeapAtGC
    wrapper.java.additional.16=-Xloggc:"%CATALINA_BASE%\logs\gc.log"

  4. Restart your instance to enable garbage collection logging.