This article mainly studies the migration of java9 gc log parameters.
Logging that unifies JVM and GC
Java9 has introduced a unified log framework, and has also included gc-related log output and configuration.
Related JEP(JDK Enhancement Proposal)
Xlog syntax
-Xlog[:option] option := [<what>][:[<output>][:[<decorators>][:<output-options>]]] 'help' 'disable' what := <selector>[,...] selector := <tag-set>[*][=<level>] tag-set := <tag>[+...] 'all' tag := name of tag level := trace debug info warning error output := 'stderr' 'stdout' [file=]<filename> decorators := <decorator>[,...] 'none' decorator := time uptime timemillis uptimemillis timenanos uptimenanos pid tid level tags output-options := <output_option>[,...] output-option := filecount=<file count> filesize=<file size in kb> parameter=value
What
Mainly configure tag and level
tag
Where all represents all tags, the others are as follows:
add, age, alloc, annotation, aot, arguments, attach, barrier, biasedlocking, blocks, bot, breakpoint, bytecode, census, class, classshisto, cleanup, compaction, comparator, constraints, constantpool, coops, cpu, cset, data, defaultmethods, d ump, ergo, event, exceptions, exit, fingerprint, freelist, gc, hashtables, heap, humongous, ihop, iklass, init, itables, jfr, jni, jvmti, liveness, load, loader, logging, mark, marking, metadata, metaspace, method, mu, modules, monitorinflatio n, monitormismatch, nmethod, normalize, objecttagging, obsolete, ooopmap, os, pagesize, parser, patch, path, phases, plab, preorder, promotion, protectiondomain, purge, redefine, ref, refine, region, remset, resolve, safepoint, scange, scru b, setting, stackmap, stacktrace, stackwalk, start, startuptime, state, stats, stringdedup, stringtable, subclass, survivor, sweep, system, task, thread, time, timer, tlab, unload, update, verification, verification, vmoperation, vtables, workgang
level
Mainly divided into off, trace, debug, info, warning, error
output
- stdout(`Sends output to stdout`)- stderr(`Sends output to stderr`)- file=filename(`Sends output to text file(s)`)
There are three types as above. If you specify a file, you can use the %p variable to represent the current jvm's pid and use %t to represent the start time stamp of jvm. for example
-Xlog:gc:demoapp-gc-%p-%t.log
The output file name is as follows:
demoapp-gc-1678-2018-03-01_21-44-18.log
decorators
If not specified, the default is uptime, level, and tags. for example
[3.080s][info][gc,cpu ] GC(5) User=0.03s Sys=0.00s Real=0.01s
Example
-Xlog:gc=trace:file=gctrace.txt:uptimemillis,pid:filecount=5,filesize=1024
tag is gc, levle is trace, rotate files are 5, each file is 1M, file name is gctrace.txt, decrotators are uptimemillis and pid
Output instance
[1110ms][1867] GC(2) Pause Remark 17M->17M(256M) 2.024ms[1110ms][1867] GC(2) Finalize Live Data 0.000ms[1110ms][1867] GC(2) Pause Cleanup 17M->17M(256M) 0.177ms[1112ms][1867] GC(2) Concurrent Cycle 7.470ms[2951ms][1867] GC(3) Pause Initial Mark (Metadata GC Threshold) 149M->30M(256M) 27.175ms[2951ms][1867] GC(4) Concurrent Cycle[2972ms][1867] GC(4) Pause Remark 32M->32M(256M) 5.132ms[2974ms][1867] GC(4) Finalize Live Data 0.000ms[2974ms][1867] GC(4) Pause Cleanup 32M->32M(256M) 0.214ms[2976ms][1867] GC(4) Concurrent Cycle 25.422ms
Migration of related parameters of old GC
| Legacy Garbage Collection (GC) Flag | Xlog Configuration | Comment |
|---|---|---|
| G1PrintHeapRegions | -Xlog:gc+region=trace | Not Applicable |
| GCLogFileSize | No configuration available | Log rotation is handled by the framework. |
| NumberOfGCLogFiles | Not Applicable | Log rotation is handled by the framework. |
| PrintAdaptiveSizePolicy | -Xlog:ergo*=level | Use a level of debug for most of the information, or a level of trace for all of what was logged for PrintAdaptiveSizePolicy. |
| PrintGC | -Xlog:gc | Not Applicable |
| PrintGCApplicationConcurrentTime | -Xlog:safepoint | Note that PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime are logged on the same tag and aren't separated in the new logging. |
| PrintGCApplicationStoppedTime | -Xlog:safepoint | Note that PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime are logged on the same tag and not separated in the new logging. |
| PrintGCCause | Not Applicable | GC cause is now always logged. |
| PrintGCDateStamps | Not Applicable | Date stamps are logged by the framework. |
| PrintGCDetails | -Xlog:gc* | Not Applicable |
| PrintGCID | Not Applicable | GC ID is now always logged. |
| PrintGCTaskTimeStamps | -Xlog:task*=debug | Not Applicable |
| PrintGCTimeStamps | Not Applicable | Time stamps are logged by the framework. |
| PrintHeapAtGC | -Xlog:gc+heap=trace | Not Applicable |
| PrintReferenceGC | -Xlog:ref*=debug | Note that in the old logging, PrintReferenceGC had an effect only if PrintGCDetails was also enabled. |
| PrintStringDeduplicationStatistics | -Xlog:stringdedup*=debug | Not Applicable |
| PrintTenuringDistribution | -Xlog:age*=level | Use a level of debug for the most relevant information, or a level of trace for all of what was logged for PrintTenuringDistribution. |
| UseGCLogFileRotation | Not Applicable | What was logged for PrintTenuringDistribution. |
Legacy runtime parameter migration
| Legacy Runtime Flag | Xlog Configuration | Comment |
|---|---|---|
| TraceExceptions | -Xlog:exceptions=info | Not Applicable |
| TraceClassLoading | -Xlog:class+load=level | Use level=info for regular information, or level=debug for additional information. In Unified Logging syntax, -verbose:class equals -Xlog:class+load=info,class+unload=info. |
| TraceClassLoadingPreorder | -Xlog:class+preorder=debug | Not Applicable |
| TraceClassUnloading | -Xlog:class+unload=level | Use level=info for regular information, or level=trace for additional information. In Unified Logging syntax, -verbose:class equals -Xlog:class+load=info,class+unload=info. |
| VerboseVerification | -Xlog:verification=info | Not Applicable |
| TraceClassPaths | -Xlog:class+path=info | Not Applicable |
| TraceClassResolution | -Xlog:class+resolve=debug | Not Applicable |
| TraceClassInitialization | -Xlog:class+init=info | Not Applicable |
| TraceLoaderConstraints | -Xlog:class+loader+constraints=info | Not Applicable |
| TraceClassLoaderData | -Xlog:class+loader+data=level | Use level=debug for regular information or level=trace for additional information. |
| TraceSafepointCleanupTime | -Xlog:safepoint+cleanup=info | Not Applicable |
| TraceSafepoint | -Xlog:safepoint=debug | Not Applicable |
| TraceMonitorInflation | -Xlog:monitorinflation=debug | Not Applicable |
| TraceBiasedLocking | -Xlog:biasedlocking=level | Use level=info for regular information, or level=trace for additional information. |
| TraceRedefineClasses | -Xlog:redefine+class*=level | level=info, =debug, and =trace provides increasing amounts of information. |
Java9 also unifies the selection and output of gc log into Xlog, and can be migrated according to the migration table given by the official.