How to create useful GC and Safepoint Logs

 In Censum, Garbage Collection, Java, Products

How to create GC logs and (optionally) their corresponding Safepoint logs

Censum can now perform analysis on both GC and Safepoint logs.  Here’s how to get the most information from your log file.

GC Log flags you need to set:

These flags ensure that the minimum set of GC data required to perform most types of analysis is printed out to a GC log,which is separate from your application log!

  • -XX:+PrintGCDetails
  • -XX:+PrintTenuringDistribution
  • -Xloggc:<Location to write your GC log to>

For example:

java -XX:+PrintGCDetails -XX:+PrintTenuringDistribution -Xloggc:gc.log -jar myApp.jar

<Optional> The following GC flags are also recommended:

The following flags ensure that you can see the actual wall clock date and time of your GC events (so you can correlate with application logs) and get some more insights as to the cause of GCs and the amount of time it takes the JVM prepare and cleanup after a GC cycle.

  • -XX:+PrintGCCause
  • -XX:+PrintGCApplicationStoppedTime
  • -XX:+PrintGCDateStamps

<Optional> Recommended Safepoint Log flags:

In order to create a Safepoint log and discover other non GC reasons for your JVM pausing, you need to have the following flags set.

WARNING: -XX:+UnlockDiagnosticVMOptions must be the first flag.
WARNING: -XX:+PrintSafepointStatistics does also print to stdout.

  • -XX:+UnlockDiagnosticVMOptions
  • -XX:+PrintSafepointStatistics
  • -XX:+LogVMOutput
  • -XX:LogFile=<Location to write your Safepoint log to>

For example:

java -XX:+UnlockDiagnosticVMOptions <other various GC log flags> -XX:+PrintSafepointStatistics -XX:+LogVMOutput -XX:LogFile=safepoint.log -jar myApp.jar

Loading a GC log

You can use File -> Open -> Open to open the GC log.

Loading an accompanying Safepoint log

You can use File -> Open -> Safepoint to open the corresponding Safepoint log for your GC log. A
Safepoint log section will appear in the left hand side of Censum.


Note, GC log file formats have not been standardized and are subject to change between JVMs and collectors. If
your log file cannot be parsed by Censum, please email a copy to along with JVM version (java -version) and its configuration parameters -XX:+PrintFlagsFinal.


Martijn (CEO) and the jClarity Team!

Recent Posts