java9中gc log参数迁移
序
本文主要研究一下java9gclog参数的迁移。
统一JVM及GC的Logging
java9引进了一个统一的日志框架,把gc相关的log输出及配置也给纳入进来了。
相关JEP(JDKEnhancementProposal)
- JEP158:UnifiedJVMLogging
- JEP264:PlatformLoggingAPIandService
- JEP271:UnifiedGCLogging
Xlog语法
-Xlog[:option] option:=[][:[
what
主要是配置tag及level
tag
其中all代表所有的tag,其他的如下:
add,age,alloc,annotation,aot,arguments,attach,barrier,biasedlocking,blocks,bot,breakpoint,bytecode,census,class,classhisto,cleanup,compaction,comparator,constraints,constantpool,coops,cpu,cset,data,defaultmethods,dump,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,mmu,modules,monitorinflation,monitormismatch,nmethod,normalize,objecttagging,obsolete,oopmap,os,pagesize,parser,patch,path,phases,plab,preorder,promotion,protectiondomain,purge,redefine,ref,refine,region,remset,resolve,safepoint,scavenge,scrub,setting,stackmap,stacktrace,stackwalk,start,startuptime,state,stats,stringdedup,stringtable,subclass,survivor,sweep,system,task,thread,time,timer,tlab,unload,update,verification,verify,vmoperation,vtables,workgang
level
主要分off,trace,debug,info,warning,error
output
-stdout(`Sendsoutputtostdout`) -stderr(`Sendsoutputtostderr`) -file=filename(`Sendsoutputtotextfile(s)`)
有如上三种,其中指定file的话,可以使用%p变量表示当前jvm的pid,用%t表示jvm的启动时间戳。比如
-Xlog:gc:demoapp-gc-%p-%t.log
输出的文件名如下:
demoapp-gc-1678-2018-03-01_21-44-18.log
decorators
- time--CurrenttimeanddateinISO-8601format
- uptime--TimesincethestartoftheJVMinsecondsandmilliseconds(e.g.,6.567s)
- timemillis--ThesamevalueasgeneratedbySystem.currentTimeMillis()
- uptimemillis--MillisecondssincetheJVMstarted
- timenanos--ThesamevalueasgeneratedbySystem.nanoTime()
- uptimenanos--NanosecondssincetheJVMstarted
- pid--Theprocessidentifier
- tid--Thethreadidentifier
- level--Thelevelassociatedwiththelogmessage
- tags--Thetag-setassociatedwiththelogmessage
不指定的话,默认是uptime,level,andtags这三个。比如
[3.080s][info][gc,cpu]GC(5)User=0.03sSys=0.00sReal=0.01s
实例
-Xlog:gc=trace:file=gctrace.txt:uptimemillis,pid:filecount=5,filesize=1024
tag为gc,levle为trace,rotate文件数为5,每个文件1M,文件名为gctrace.txt,decrotators为uptimemillis和pid
输出实例
[1110ms][1867]GC(2)PauseRemark17M->17M(256M)2.024ms [1110ms][1867]GC(2)FinalizeLiveData0.000ms [1110ms][1867]GC(2)PauseCleanup17M->17M(256M)0.177ms [1112ms][1867]GC(2)ConcurrentCycle7.470ms [2951ms][1867]GC(3)PauseInitialMark(MetadataGCThreshold)149M->30M(256M)27.175ms [2951ms][1867]GC(4)ConcurrentCycle [2972ms][1867]GC(4)PauseRemark32M->32M(256M)5.132ms [2974ms][1867]GC(4)FinalizeLiveData0.000ms [2974ms][1867]GC(4)PauseCleanup32M->32M(256M)0.214ms [2976ms][1867]GC(4)ConcurrentCycle25.422ms
迁移
旧版GC相关参数迁移
LegacyGarbageCollection(GC)Flag | XlogConfiguration | Comment |
---|---|---|
G1PrintHeapRegions | -Xlog:gc+region=trace | NotApplicable |
GCLogFileSize | Noconfigurationavailable | Logrotationishandledbytheframework. |
NumberOfGCLogFiles | NotApplicable | Logrotationishandledbytheframework. |
PrintAdaptiveSizePolicy | -Xlog:ergo*=level | Usealevelofdebugformostoftheinformation,oraleveloftraceforallofwhatwasloggedforPrintAdaptiveSizePolicy. |
PrintGC | -Xlog:gc | NotApplicable |
PrintGCApplicationConcurrentTime | -Xlog:safepoint | NotethatPrintGCApplicationConcurrentTimeandPrintGCApplicationStoppedTimeareloggedonthesametagandaren'tseparatedinthenewlogging. |
PrintGCApplicationStoppedTime | -Xlog:safepoint | NotethatPrintGCApplicationConcurrentTimeandPrintGCApplicationStoppedTimeareloggedonthesametagandnotseparatedinthenewlogging. |
PrintGCCause | NotApplicable | GCcauseisnowalwayslogged. |
PrintGCDateStamps | NotApplicable | Datestampsareloggedbytheframework. |
PrintGCDetails | -Xlog:gc* | NotApplicable |
PrintGCID | NotApplicable | GCIDisnowalwayslogged. |
PrintGCTaskTimeStamps | -Xlog:task*=debug | NotApplicable |
PrintGCTimeStamps | NotApplicable | Timestampsareloggedbytheframework. |
PrintHeapAtGC | -Xlog:gc+heap=trace | NotApplicable |
PrintReferenceGC | -Xlog:ref*=debug | Notethatintheoldlogging,PrintReferenceGChadaneffectonlyifPrintGCDetailswasalsoenabled. |
PrintStringDeduplicationStatistics | -Xlog:stringdedup*=debug | NotApplicable |
PrintTenuringDistribution | -Xlog:age*=level | Usealevelofdebugforthemostrelevantinformation,oraleveloftraceforallofwhatwasloggedforPrintTenuringDistribution. |
UseGCLogFileRotation | NotApplicable | WhatwasloggedforPrintTenuringDistribution. |
旧版运行时参数迁移
LegacyRuntimeFlag | XlogConfiguration | Comment |
---|---|---|
TraceExceptions | -Xlog:exceptions=info | NotApplicable |
TraceClassLoading | -Xlog:class+load=level | Uselevel=infoforregularinformation,orlevel=debugforadditionalinformation.InUnifiedLoggingsyntax,-verbose:classequals-Xlog:class+load=info,class+unload=info. |
TraceClassLoadingPreorder | -Xlog:class+preorder=debug | NotApplicable |
TraceClassUnloading | -Xlog:class+unload=level | Uselevel=infoforregularinformation,orlevel=traceforadditionalinformation.InUnifiedLoggingsyntax,-verbose:classequals-Xlog:class+load=info,class+unload=info. |
VerboseVerification | -Xlog:verification=info | NotApplicable |
TraceClassPaths | -Xlog:class+path=info | NotApplicable |
TraceClassResolution | -Xlog:class+resolve=debug | NotApplicable |
TraceClassInitialization | -Xlog:class+init=info | NotApplicable |
TraceLoaderConstraints | -Xlog:class+loader+constraints=info | NotApplicable |
TraceClassLoaderData | -Xlog:class+loader+data=level | Uselevel=debugforregularinformationorlevel=traceforadditionalinformation. |
TraceSafepointCleanupTime | -Xlog:safepoint+cleanup=info | NotApplicable |
TraceSafepoint | -Xlog:safepoint=debug | NotApplicable |
TraceMonitorInflation | -Xlog:monitorinflation=debug | NotApplicable |
TraceBiasedLocking | -Xlog:biasedlocking=level | Uselevel=infoforregularinformation,orlevel=traceforadditionalinformation. |
TraceRedefineClasses | -Xlog:redefine+class*=level | level=info,=debug,and=traceprovideincreasingamountsofinformation. |
小结
java9把gclog的选型及输出也给统一到了Xlog中,可以按照官方给出的迁移表进行迁移。
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。