How to enable verbose GC in tomcat

The Problem

Where do I put the “Enable verbose GC” setting in Tomcat? Is there a switch or something?

The Fix

The file that you should use to enable verbose gc for Tomcat ( Or for the JVM that Tomcat is running in ) is $TOMCAT_HOME/bin/ This file might not exist in your install so when you create the file it will be loaded from the $TOMCAT_HOME/bin/ script. Here is the snip from around line 110 in

if [ -r "$CATALINA_BASE"/bin/ ]; then
 . "$CATALINA_BASE"/bin/
elif [ -r "$CATALINA_HOME"/bin/ ]; then
 . "$CATALINA_HOME"/bin/

Here is an example file with verbose gc enabled, look at the bold part:

JAVA_OPTS="-Xms256m -Xmx512m \
  -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -verbose:gc -Xloggc:/tmp/gc.log"

 -Djava.library.path=/usr/local/apr/lib \
 -Djava.awt.headless=true \ \ \ \"


Now restart tomcat and you are done!


One response to this post.

  1. Posted by kai on August 31, 2011 at 9:18 AM

    Your blog post helped me. Thank you for sharing!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: