Enabling GC logging provides great benefits such as: reducing overall application response time, troubleshooting memory problems, forecast outages, and doing effective capacity planning… Contrary to common thinking, enabling GC logging doesn’t add any noticeable overhead to your application. Thus, we strongly recommend you enable GC logging on all your production servers.

Enabling GC logs

GC Logging can be enabled by passing below-mentioned JVM arguments during application startup

Until Java 8:

If your application is running on Java 8 or below version, pass below JVM arguments:

-XX:+PrintGCDetails -Xloggc:<gc-log-file-path>


-XX:+PrintGCDetails -Xloggc:/opt/tmp/myapp-gc.log

From Java 9:

If your application is running on Java 9 or above version, pass below JVM arguments:




How to analyze GC logs?

Here is a sample GC log generated when above system properties were passed:

What is GC

GC log has rich information, however, understanding GC log is not easy. There isn’t sufficient documentation to explain GC log format. On top of it, GC log format is not standardized. It varies by JVM vendor (Oracle, IBM, HP, Azul, …), Java version (1.4, 5, 6, 7, 8, 9), GC algorithm (Serial, Parallel, CMS, G1, Shenandoah), GC system properties that you pass (-XX:+PrintGC, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintHeapAtGC …). Based on this permutation and combination, there are easily 60+ different GC log formats.

Thus, to analyze GC logs, it’s highly recommended to use GC log analysis tools such as GCeasy, HPJmeter. These tools parse GC logs and generate great graphical visualizations of data, reports Key Performance Indicators and several other useful metrics.

Here is a sample GC log analysis report generated by the GCeasy tool.