In Java 9 and onwards, OpenJDK introduced the unified logging framework for logging. See JEP 158 for details.
Garbage collection (GC) logging now leverages this framework in Java 9 and later releases. See JEP 271. GC arguments that you currently have in place for Java 8 won't work in Java 11. For additional details, watch the following sessions:
- QCon session by Twitter's Tony Printezis from 2016
- Devoxx session by Oracle's Poonam Parhar from March 2017
- Bangalore JUG (Java User Group) session by Oracle's Fairoz Matte from September 2017
This new logging framework introduces the concept of log levels, tags, and decorators, with gc being one of the tags. Try the command:
java -Xlog:help
The following table lists all of the log levels:
# | Log Level |
---|---|
off | |
error | |
warning | |
info | |
debug | |
trace |
The basic format to use is this:
-Xlog:tags_loglevel:output_destination:decorators:output_options
- You can pass in the following argument for AEM. %p represents the process ID of the Java process. %t prints the timestamp for when the log was created. Maximum file size is 50 MB, and file rollover happens after 10 files:
-Xlog:gc*,gc+ref=debug,gc+heap=debug,gc+age=trace:file=gc-%p-%t.log:tags,uptime,time,level:filecount=10,filesize=50m
- Although safepoints are not always related to garbage collection, they do affect the performance of the application. For example, thread dumps require the JVM to reach a safepoint. Out of the box, AEM triggers thread dumps every minute! (this behaviour can be configured better in /system/console/configMgr). Therefore we need to keep track of JVM pauses caused by safepoints (in a separate log file). So adding the following is a good idea as well. For more on JVM safepoints, watch this 2015 session by Azul's John Cuthbertson.
-Xlog:safepoint*:file=safepoints-%p-%t.log:tags,uptime,time,level:filecount=10,filesize=50m