How to Convert JDK8 GC Log Flags to JDK9 with Unified Logging:
Introduction:
JDK9 introduced unified logging for all JDK9 components. It provides a way for the users to configure the content of the logs. Since all the logs follow the unified format, it would make parsing easier.
Users might have some difficulty finding the right tags and levels in JDK9, especially when migrating from JDK8.
Users might have some difficulty finding the right tags and levels in JDK9, especially when migrating from JDK8.
This post provides some basic back ground about unified logging in JDK9, and tags and levels in JDK9 corresponding to JDK8 flags for GC logging.
JDK9 Unified Logging:
With a JDK9 build, you can logging help by "java -Xlog:help". Here is the output from the command
./bin/java -Xlog:help
-Xlog Usage: -Xlog[:[what][:[output][:[decorators][:output-options]]]]
where 'what' is a combination of tags and levels on the form tag1[+tag2...][*][=level][,...]
Unless wildcard (*) is specified, only log messages tagged with exactly the tags specified will be matched.
Available log levels:
off, trace, debug, info, warning, error
Available log decorators:
time (t), utctime (utc), uptime (u), timemillis (tm), uptimemillis (um), timenanos (tn), uptimenanos (un), hostname (hn), pid (p), tid (ti), level (l), tags (tg)
Decorators can also be specified as 'none' for no decoration.
Available log tags:
add, age, alloc, aot, annotation, arguments, attach, barrier, biasedlocking, blocks, bot, breakpoint, census, class, classhisto, cleanup, compaction, constraints, constantpool, coops, cpu, cset, data, defaultmethods, dump, ergo, exceptions, exit, fingerprint, freelist, gc, hashtables, heap, humongous, ihop, iklass, init, itables, jni, jvmti, liveness, load, loader, logging, mark, marking, methodcomparator, metadata, metaspace, mmu, modules, monitorinflation, monitormismatch, nmethod, normalize, objecttagging, obsolete, oopmap, os, pagesize, patch, path, phases, plab, promotion, preorder, protectiondomain, ref, redefine, refine, region, remset, purge, resolve, safepoint, scavenge, scrub, stacktrace, stackwalk, start, startuptime, state, stats, stringdedup, stringtable, stackmap, subclass, survivor, sweep, task, thread, tlab, time, timer, update, unload, verification, verify, vmoperation, vtables, workgang, jfr, system, parser, bytecode, setting, event
Specifying 'all' instead of a tag combination matches all tag combinations.
Described tag combinations:
logging: Logging for the log framework itself
Available log outputs:
stdout, stderr, file=<filename>
Specifying %p and/or %t in the filename will expand to the JVM's PID and startup timestamp, respectively.
Some examples:
-Xlog
Log all messages using 'info' level to stdout with 'uptime', 'levels' and 'tags' decorations.
(Equivalent to -Xlog:all=info:stdout:uptime,levels,tags).
-Xlog:gc
Log messages tagged with 'gc' tag using 'info' level to stdout, with default decorations.
-Xlog:gc=debug:file=gc.txt:none
Log messages tagged with 'gc' tag using 'debug' level to file 'gc.txt' with no decorations.
-Xlog:gc=trace:file=gctrace.txt:uptimemillis,pids:filecount=5,filesize=1m
Log messages tagged with 'gc' tag using 'trace' level to a rotating fileset of 5 files of size 1MB,
using the base name 'gctrace.txt', with 'uptimemillis' and 'pid' decorations.
-Xlog:gc::uptime,tid
Log messages tagged with 'gc' tag using 'info' level to output 'stdout', using 'uptime' and 'tid' decorations.
-Xlog:gc*=info,safepoint*=off
Log messages tagged with at least 'gc' using 'info' level, but turn off logging of messages tagged with 'safepoint'.
(Messages tagged with both 'gc' and 'safepoint' will not be logged.)
-Xlog:disable -Xlog:safepoint=trace:safepointtrace.txt
Turn off all logging, including warnings and errors,
and then enable messages tagged with 'safepoint' using 'trace' level to file 'safepointtrace.txt'.
JDK8 GC Logging Flags to JDK9 Tags and Levels:
Here I listed the most commonly used GC logging flags for JDK8, JDK9 tags and levels and some examples:
JDK8 | JDK9 | description |
-XX:+PrintGC -Xloggc:<filename> | -Xlog:gc:<filename> | Log messages tagged with 'gc' tag using 'info' level to stdout, with default decorations. |
-XX:+PrintGCDetails -Xloggc:<filename> | -Xlog:gc=info | print GC Detail. old: prints phases, cputime, heap sizes ul: can print those separately as controlled by the tag. |
-Xlog:gc=info,phases*=debug | add detailed phases info | |
-XX:+PrintGCDetails -XX:+UnlockDiagnosticVMOptions -XX:+G1SummarizeRSetStats -XX:G1SummarizeRSetStatsPeriod=<n> -Xloggc:<filename> | -XX:G1SummarizeRSetStatsPeriod=<n> -Xlog:gc=info,remset*=trace:<filename> | Print remember set memory footprint, and table usage statistics. This could be an expensive operation |
-XX:+PrintTenuringDistribution -Xloggc:<filename> | -Xlog:gc=info,heap*=info,phases*=debug,gc+age=debug:<filename> or -Xlog:gc=info,heap*=info,phases*=debug,gc+age=trace:<filename> |
Age distribution in survivor space |
-XX:+PrintAdaptiveSizePolicy -Xloggc:<filename> | -Xlog:gc=info,gc+ergo*=debug:$log_dir/gc.log | information related to ergonomic decision makeing, such as CSET and IHOP |
-XX:+PrintTLAB | -Xlog:gc=info,gc+tlab=debug:$log_dir/gc.log - prints total or -Xlog:gc=info,gc+tlab=trace:$log_dir/gc.log - prints per thread info |
TLAB |
-XX:PrintPLAB | -Xlog:gc=info,gc+plab=debug:$log_dir/gc.log | PLAB |
-XX:G1SummarizeConcMark | -Xlog:gc=info,gc+marking=trace:$log_dir/gc.log | print marking statistics when jvm exit |
-XX:+UnlockDiagnosticVMOptions -XX:G1TraceConcRefinement | -Xlog:gc=info,gc+refine=debug:$log_dir/gc.log | print when refinement threads are activated/deactivated |
-XX:+PrintReferenceGC | -Xlog:gc=info,gc+ref=debug:$log_dir/gc.log | reference processing data |
-XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime | -Xlog:gc=info,safepoint=info:$log_dir/gc.log or -Xlog:gc=info,safepoint=debug:$log_dir/gc.log - with per thread state |
safepoint: type of safepoint, how long to reach the safepoint |
Comments
Post a Comment