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:
- Execute the tomcat6w.exe (tomcat5w.exe for Tomcat 5.5.x) application. This displays a configuration for the Apache Tomcat Windows service.
- Click the Java tab.
- 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.
- Switch back to the General tab.
- 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:
- Open the conf/wrapper.properties file for the instance using a text editor.
- Navigate to the end of the file and look for the line that starts with wrapper.cmd_line.
- 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
- 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.
- 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:
- Open the conf/wrapper.conf file for an instance of the runtime using a text editor.
- 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.
- 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"
- Restart your instance to enable garbage collection logging.