溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

java9中g(shù)c log參數(shù)的遷移

發(fā)布時(shí)間:2021-09-02 14:58:10 來源:億速云 閱讀:172 作者:chen 欄目:編程語言

這篇文章主要講解了“java9中g(shù)c log參數(shù)的遷移”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“java9中g(shù)c log參數(shù)的遷移”吧!


本文主要研究一下java9 gc log參數(shù)的遷移。

統(tǒng)一JVM及GC的Logging

java9引進(jìn)了一個(gè)統(tǒng)一的日志框架,把gc相關(guān)的log輸出及配置也給納入進(jìn)來了。

相關(guān)JEP(JDK Enhancement Proposal)

  • JEP 158: Unified JVM Logging

  • JEP 264: Platform Logging API and Service

  • JEP 271: Unified GC Logging

Xlog語法

-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

主要是配置tag及l(fā)evel

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(`Sends output to stdout`)
- stderr(`Sends output to stderr`)
- file=filename(`Sends output to text file(s)`)

有如上三種,其中指定file的話,可以使用%p變量表示當(dāng)前jvm的pid,用%t表示jvm的啟動時(shí)間戳。比如

-Xlog:gc:demoapp-gc-%p-%t.log

輸出的文件名如下:

demoapp-gc-1678-2018-03-01_21-44-18.log

decorators

  • time -- Current time and date in ISO-8601 format

  • uptime -- Time since the start of the JVM in seconds and milliseconds (e.g., 6.567s)

  • timemillis -- The same value as generated by System.currentTimeMillis()

  • uptimemillis -- Milliseconds since the JVM started

  • timenanos -- The same value as generated by System.nanoTime()

  • uptimenanos -- Nanoseconds since the JVM started

  • pid -- The process identifier

  • tid -- The thread identifier

  • level -- The level associated with the log message

  • tags -- The tag-set associated with the log message

不指定的話,默認(rèn)是uptime, level, and tags這三個(gè)。比如

[3.080s][info][gc,cpu ] GC(5) User=0.03s Sys=0.00s Real=0.01s

實(shí)例

-Xlog:gc=trace:file=gctrace.txt:uptimemillis,pid:filecount=5,filesize=1024

tag為gc,levle為trace,rotate文件數(shù)為5,每個(gè)文件1M,文件名為gctrace.txt,decrotators為uptimemillis和pid

輸出實(shí)例

[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

遷移

舊版GC相關(guān)參數(shù)遷移

Legacy Garbage Collection (GC) FlagXlog ConfigurationComment
G1PrintHeapRegions-Xlog:gc+region=traceNot Applicable
GCLogFileSizeNo configuration availableLog rotation is handled by the framework.
NumberOfGCLogFilesNot ApplicableLog rotation is handled by the framework.
PrintAdaptiveSizePolicy-Xlog:ergo*=levelUse a level of debug for most of the information, or a level of trace for all of what was logged for PrintAdaptiveSizePolicy.
PrintGC-Xlog:gcNot Applicable
PrintGCApplicationConcurrentTime-Xlog:safepointNote that PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime are logged on the same tag and aren't separated in the new logging.
PrintGCApplicationStoppedTime-Xlog:safepointNote that PrintGCApplicationConcurrentTime and PrintGCApplicationStoppedTime are logged on the same tag and not separated in the new logging.
PrintGCCauseNot ApplicableGC cause is now always logged.
PrintGCDateStampsNot ApplicableDate stamps are logged by the framework.
PrintGCDetails-Xlog:gc*Not Applicable
PrintGCIDNot ApplicableGC ID is now always logged.
PrintGCTaskTimeStamps-Xlog:task*=debugNot Applicable
PrintGCTimeStampsNot ApplicableTime stamps are logged by the framework.
PrintHeapAtGC-Xlog:gc+heap=traceNot Applicable
PrintReferenceGC-Xlog:ref*=debugNote that in the old logging, PrintReferenceGC had an effect only if PrintGCDetails was also enabled.
PrintStringDeduplicationStatistics-Xlog:stringdedup*=debugNot Applicable
PrintTenuringDistribution-Xlog:age*=levelUse a level of debug for the most relevant information, or a level of trace for all of what was logged for PrintTenuringDistribution.
UseGCLogFileRotationNot ApplicableWhat was logged for PrintTenuringDistribution.

舊版運(yùn)行時(shí)參數(shù)遷移

Legacy Runtime FlagXlog ConfigurationComment
TraceExceptions-Xlog:exceptions=infoNot Applicable
TraceClassLoading-Xlog:class+load=levelUse 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=debugNot Applicable
TraceClassUnloading-Xlog:class+unload=levelUse 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=infoNot Applicable
TraceClassPaths-Xlog:class+path=infoNot Applicable
TraceClassResolution-Xlog:class+resolve=debugNot Applicable
TraceClassInitialization-Xlog:class+init=infoNot Applicable
TraceLoaderConstraints-Xlog:class+loader+constraints=infoNot Applicable
TraceClassLoaderData-Xlog:class+loader+data=levelUse level=debug for regular information or level=trace for additional information.
TraceSafepointCleanupTime-Xlog:safepoint+cleanup=infoNot Applicable
TraceSafepoint-Xlog:safepoint=debugNot Applicable
TraceMonitorInflation-Xlog:monitorinflation=debugNot Applicable
TraceBiasedLocking-Xlog:biasedlocking=levelUse level=info for regular information, or level=trace for additional information.
TraceRedefineClasses-Xlog:redefine+class*=levellevel=info, =debug, and =trace provide increasing amounts of information.

小結(jié)

java9把gc log的選型及輸出也給統(tǒng)一到了Xlog中,可以按照官方給出的遷移表進(jìn)行遷移。

感謝各位的閱讀,以上就是“java9中g(shù)c log參數(shù)的遷移”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對java9中g(shù)c log參數(shù)的遷移這一問題有了更深刻的體會,具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識點(diǎn)的文章,歡迎關(guān)注!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI