当前位置: 首页 > news >正文

java9 gc log参数迁移

本文主要研究一下java9 gc log参数的迁移。

统一JVM及GC的Logging

java9引进了一个统一的日志框架,对gc log的输出进行了统一的配置。

相关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及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(`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文件数为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相关参数迁移

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.

旧版运行时参数迁移

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.

小结

java9把gc log的配置统一到了Xlog中,可以按照官方给出的新旧参数映射表进行迁移。

doc

  • Enable Logging with the JVM Unified Logging Framework
  • -Xlog Output
  • Convert GC Logging Flags to Xlog
  • Convert Runtime Logging Flags to Xlog

相关文章:

  • NSURL
  • MySQL数据库----流程控制
  • windowsPhone开发(什么是手机开发?)
  • 记一次内存溢出的分析经历——thrift带给我的痛orz
  • [精华][推荐]CAS SSO 单点登录框架学习 环境搭建
  • 部门机关名称/部门人员名称的获取
  • 2017,技术年度总结篇
  • C++11 中值得关注的几大变化(详解)
  • 8-angular 要点温习-1
  • 收集一些网络检测和分析工具
  • 滴滴发布智慧交通战略产品“交通大脑”
  • 如何运用互联网手机等新兴媒体开展群众工作
  • 专家称GIS技术拥抱大数据已成热潮
  • POJ 2392 Space Elevator(多重背包 + 倍增优化)
  • CSS:让IE6/IE7支持display:inline-block
  • 【399天】跃迁之路——程序员高效学习方法论探索系列(实验阶段156-2018.03.11)...
  • 5、React组件事件详解
  • eclipse的离线汉化
  • java8 Stream Pipelines 浅析
  • java中的hashCode
  • Python学习之路16-使用API
  • Sublime Text 2/3 绑定Eclipse快捷键
  • vue脚手架vue-cli
  • windows下mongoDB的环境配置
  • 不发不行!Netty集成文字图片聊天室外加TCP/IP软硬件通信
  • 力扣(LeetCode)965
  • 学习ES6 变量的解构赋值
  • 一个SAP顾问在美国的这些年
  • 这几个编码小技巧将令你 PHP 代码更加简洁
  • 主流的CSS水平和垂直居中技术大全
  • Nginx惊现漏洞 百万网站面临“拖库”风险
  • ​DB-Engines 12月数据库排名: PostgreSQL有望获得「2020年度数据库」荣誉?
  • #、%和$符号在OGNL表达式中经常出现
  • #在线报价接单​再坚持一下 明天是真的周六.出现货 实单来谈
  • (2)nginx 安装、启停
  • (C++17) optional的使用
  • (pojstep1.1.1)poj 1298(直叙式模拟)
  • (PWM呼吸灯)合泰开发板HT66F2390-----点灯大师
  • (附源码)springboot 房产中介系统 毕业设计 312341
  • (三)elasticsearch 源码之启动流程分析
  • (原創) 如何安裝Linux版本的Quartus II? (SOC) (Quartus II) (Linux) (RedHat) (VirtualBox)
  • (转)【Hibernate总结系列】使用举例
  • *** 2003
  • .net 设置默认首页
  • .NET/C# 避免调试器不小心提前计算本应延迟计算的值
  • .NET简谈互操作(五:基础知识之Dynamic平台调用)
  • .NET命名规范和开发约定
  • .NET设计模式(7):创建型模式专题总结(Creational Pattern)
  • .net实现头像缩放截取功能 -----转载自accp教程网
  • .NET中两种OCR方式对比
  • .w文件怎么转成html文件,使用pandoc进行Word与Markdown文件转化
  • @Autowired自动装配
  • @DependsOn:解析 Spring 中的依赖关系之艺术
  • [2009][note]构成理想导体超材料的有源THz欺骗表面等离子激元开关——
  • [BROADCASTING]tensor的扩散机制