Enabling garbage collection logging with Tomcat on Windows platform
search cancel

Enabling garbage collection logging with Tomcat on Windows platform

book

Article ID: 293364

calendar_today

Updated On:

Products

VMware Tanzu tc Server

Environment


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.

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.