Visit Azul.com Support

Using GC Log Analyzer

Table of Contents
Need help?
Schedule a consultation with an Azul performance expert.
Contact Us

Garbage Collector Log Analyzer (GC Log Analyzer) gives you insights in the logs generated by your Java runtime.

Running GCLA

Download GCLA as described in About GC Log Analyzer > Download GCLA and run it with the following command in any terminal or command prompt window:

 
java -Xmx4g -jar GCLogAnalyzer2.jar gc.log

To run GC Log Analyzer in a non-GUI mode and create an HTML output, use the following as an example:

 
java -jar GCLogAnalyzer2.jar --generate-html ./output-html ./gc.log

This generates ./output-html/all-graphs.html. If you need a batch of json files with data from your <logfile>, use:

 
java -jar GCLogAnalyzer2.jar [--generate-html <dir> [--resize WxH]] [--dump-raw-data <dir>] gc.log

Using GCLA

You can find detailed usage instructions in the GC Log Analyzer documentation website.

How to Enable GC Logging

To use GC Log Analyzer, it is necessary to first have a GC log to analyze. GC logging is enabled with the Java command line argument -Xlog. This has been available since Java 9, thanks to JEP 158: Unified JVM Logging.

To collect a GC log with basic information into a file, use -Xlog:gc:/path/to/file.log.

To get more information in the log, use one of the following options:

  • -Xlog:gc,safepoint:/path/to/file.log to enable default logging of the important garbage collection events including all safepoint pauses.

  • -Xlog:gc*,safepoint:/path/to/file.log to enable more detailed logging, including all safepoint pauses and smaller garbage collector events and phases that are normally not logged. For OpenJDK, this is often needed as otherwise some Java heap memory metrics are not recorded, and not all pauses are tracked. The tradeoff between gc and gc* is usually 10 times more log data amount, which reduces the time interval your log covers.

  • -Xlog:gc,safepoint to write the log data to stdout, which can be helpful in containers to avoid storing local log files.

  • -Xlog:gc,safepoint:/path/to/file.log::filecount=10,filesize=100M to change the default log rotation of 5 files of 20 MBytes each to 10 files of 100 MBytes each. Note the double colon.

  • -Xlog:gc,safepoint:/path/to/file.log::filecount=0 to disable log file rotation, useful for quick test runs or for processes that are restarted often. Note the double colon.

You can even repeat the -Xlog argument and use it to specify different outputs at the same time, for example, the following writes it to stdout and to a local file:

 
$ java -Xlog:gc,safepoint -Xlog:gc,safepoint:/opt/log/gc.log -jar myApp.jar

There are more options available with the unified logging system, as you can see when you run the following command:

 
$ java -Xlog:logging=debug -version [0.017s][info][logging] Log configuration fully initialized. [0.017s][info][logging] Available log levels: off, trace, debug, info, warning, error [0.017s][info][logging] Available log decorators: time (t), utctime (utc), uptime (u), timemillis (tm), uptimemillis (um),... [0.017s][info][logging] Available log tags: add, age,... gc,... [0.017s][info][logging] Described tag sets: [0.017s][info][logging] logging: Logging for the log framework itself [0.019s][debug][logging] Available tag sets: , arguments, attach, cds, cds+class, cds+dynamic, cds+hashtables, cds+heap,... [0.023s][info ][logging] Log output configuration: [0.023s][info ][logging] #0: stdout all=warning,logging=debug uptime,level,tags foldmultilines=false [0.023s][info ][logging] #1: stderr all=off uptime,level,tags foldmultilines=false openjdk version "22" 2024-03-19 OpenJDK Runtime Environment Zulu22.28+91-CA (build 22+36) OpenJDK 64-Bit Server VM Zulu22.28+91-CA (build 22+36, mixed mode, sharing)