java9 gc log參數(shù)遷移

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

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

java9引進了一個統(tǒng)一的日志框架瓢喉,對gc log的輸出進行了統(tǒng)一的配置。

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

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變量表示當前jvm的pid墩瞳,用%t表示jvm的啟動時間戳。比如

-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

不指定的話氏豌,默認是uptime, level, and tags這三個喉酌。比如

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

實例

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

tag為gc,levle為trace泵喘,rotate文件數(shù)為5泪电,每個文件1M,文件名為gctrace.txt涣旨,decrotators為uptimemillis和pid

輸出實例

[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) 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.

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

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 provide increasing amounts of information.

小結(jié)

java9把gc log的配置統(tǒng)一到了Xlog中歪架,可以按照官方給出的新舊參數(shù)映射表進行遷移。

doc

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末霹陡,一起剝皮案震驚了整個濱河市和蚪,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌烹棉,老刑警劉巖攒霹,帶你破解...
    沈念sama閱讀 222,000評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異浆洗,居然都是意外死亡催束,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,745評論 3 399
  • 文/潘曉璐 我一進店門伏社,熙熙樓的掌柜王于貴愁眉苦臉地迎上來抠刺,“玉大人,你說我怎么就攤上這事摘昌∷傺” “怎么了?”我有些...
    開封第一講書人閱讀 168,561評論 0 360
  • 文/不壞的土叔 我叫張陵聪黎,是天一觀的道長罕容。 經(jīng)常有香客問我,道長稿饰,這世上最難降的妖魔是什么锦秒? 我笑而不...
    開封第一講書人閱讀 59,782評論 1 298
  • 正文 為了忘掉前任,我火速辦了婚禮喉镰,結(jié)果婚禮上旅择,老公的妹妹穿的比我還像新娘。我一直安慰自己侣姆,他們只是感情好生真,可當我...
    茶點故事閱讀 68,798評論 6 397
  • 文/花漫 我一把揭開白布脖咐。 她就那樣靜靜地躺著,像睡著了一般汇歹。 火紅的嫁衣襯著肌膚如雪屁擅。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,394評論 1 310
  • 那天产弹,我揣著相機與錄音派歌,去河邊找鬼。 笑死痰哨,一個胖子當著我的面吹牛胶果,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播斤斧,決...
    沈念sama閱讀 40,952評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼早抠,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了撬讽?” 一聲冷哼從身側(cè)響起蕊连,我...
    開封第一講書人閱讀 39,852評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎游昼,沒想到半個月后甘苍,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,409評論 1 318
  • 正文 獨居荒郊野嶺守林人離奇死亡烘豌,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,483評論 3 341
  • 正文 我和宋清朗相戀三年载庭,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片廊佩。...
    茶點故事閱讀 40,615評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡囚聚,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出标锄,到底是詐尸還是另有隱情顽铸,我是刑警寧澤,帶...
    沈念sama閱讀 36,303評論 5 350
  • 正文 年R本政府宣布鸯绿,位于F島的核電站跋破,受9級特大地震影響簸淀,放射性物質(zhì)發(fā)生泄漏瓶蝴。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,979評論 3 334
  • 文/蒙蒙 一租幕、第九天 我趴在偏房一處隱蔽的房頂上張望舷手。 院中可真熱鬧,春花似錦劲绪、人聲如沸男窟。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,470評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽歉眷。三九已至牺六,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間汗捡,已是汗流浹背淑际。 一陣腳步聲響...
    開封第一講書人閱讀 33,571評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留扇住,地道東北人春缕。 一個月前我還...
    沈念sama閱讀 49,041評論 3 377
  • 正文 我出身青樓,卻偏偏與公主長得像艘蹋,于是被迫代替她去往敵國和親锄贼。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 45,630評論 2 359

推薦閱讀更多精彩內(nèi)容