GC logs are vital artifacts to troubleshoot memory/CPU related problems and optimize applications performance. In Sep 2017, much-awaited java 9 got released. In Java 9, GC logging has been re-implemented using Unified GC logging framework (JEP 271). Some changes are surprising and some changes might be shocking.
Here are the changes made to GC logging in Java 9:
- 3 popular GC logging system properties deprecated
- 43 GC logging system properties are removed (Note: it’s ‘removed’ and not ‘deprecated’)
- GC log format changed
This article walks you through the steps that you need to follow when migrating the applications to Java 9.
3 popular GC logging system properties deprecated
Most java applications use these 3 GC logging system properties, commonly: -XX:+PrintGC, -XX:+PrintGCDetails, and -Xloggc:<gc-log-file-path>. All these 3 system properties are deprecated in Java 9; they will be removed in upcoming Java releases. It’s advised to replace these system properties with the newly introduced system properties in java 9.
Here are the old systems properties equivalents in Java 9.
|Till Java 8||From Java 9|
43 GC logging system properties removed
First, it’s a surprise to several of us that Java has 43 GC logging system properties. The second surprise is all these 43 GC logging system properties are removed. Yes, they are removed, not even deprecated. JVM will not start if you are passing old system properties. Thus, you are forced to replace these system properties in Java 9. This table summarizes the old System properties and their equivalents in Java 9.
GC log format change
Java GC log format is migrated to ‘Unified JVM Logging‘ framework in java 9. Thus, GC logs will start to look different from the earlier versions. Assume if you are using G1 GC, then below is how GC log format would have been looking for Java 8:
In Java 9, GC log will start to look like as shown below:
You can see additional information such as relative time (i.e. ‘[2.799s]’), log level (i.e. trace, debug, info..), and GC event number (i.e. GC(0)) printed in Java 9 GC log format, which were prevented in java 8. Besides the new additions, there are also changes in the certain events as well.
This format change is applicable to all GC algorithms (i.e. Serial, CMS, Parallel, Shenandoah) as well and not just G1 GC. So, if you are using any custom scripts/tools to analyze GC logs, those scripts/tools will need to be enhanced to support this new format.