资讯专栏INFORMATION COLUMN

java9 gc log参数迁移

Kahn / 3483人阅读

摘要:序本文主要研究一下参数的迁移。比如实例为,为,文件数为,每个文件,文件名为,为和输出实例迁移旧版相关参数迁移旧版运行时参数迁移小结把的配置统一到了中,可以按照官方给出的新旧参数映射表进行迁移。

本文主要研究一下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         :=  [][:[][:[][:]]]
                       "help"
                       "disable"
    what           :=  [,...]
    selector       :=  [*][=]
    tag-set        :=  [+...]
                       "all"
    tag            :=  name of tag
    level          :=  trace
                       debug
                       info
                       warning
                       error
    output         :=  "stderr"
                       "stdout"
                       [file=]
    decorators     :=  [,...]
                       "none"
    decorator      :=  time
                       uptime
                       timemillis
                       uptimemillis
                       timenanos
                       uptimenanos
                       pid
                       tid
                       level
                       tags
    output-options :=  [,...]
    output-option  :=  filecount=
                       filesize=
                       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) 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 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.
小结

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

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/68647.html

相关文章

  • Java9的新特性

    摘要:新特性概述系列一安装及使用系列二运行系列三模块系统精要系列四更新系列五系列六系列七系列八系列九与的区别迁移注意事项参数迁移相关选项解析使用构建实例使用示例带你提前了解中的新特性 Java语言特性系列 Java5的新特性 Java6的新特性 Java7的新特性 Java8的新特性 Java9的新特性 Java10的新特性 Java11的新特性 Java12的新特性 Java13的新特性...

    ddongjian0000 评论0 收藏0
  • Java9模块化学习笔记三之迁移Java9

    摘要:命令行参数文件鉴于迁移到后可能需要很长的命令行参数,有些会限制命令行长度,支持定义一个命令行参数文件。已有三分库可以自动转成模块,只要在启动时将放在指定路径中,便会自动变成。 java[c]命令行参数文件 鉴于迁移到java9后可能需要很长的命令行参数,有些os会限制命令行长度,java9支持定义一个命令行参数文件。使用方式: java @arguments.txt arguments...

    NeverSayNever 评论0 收藏0
  • JAVA9-12新特性简述

    摘要:本文是个人在企业内部分享使用的简要大纲,列举了的重要更新,文章的结构较简单,也不规范,鉴于近期写若干文章时总会忘记一些新特性所处的版本,特将此大纲流留用。 本文是个人在企业内部分享使用的简要大纲,列举了JAVA9-12的重要更新,文章的结构较简单,也不规范,鉴于近期写若干文章时总会忘记一些新特性所处的版本,特将此大纲流copy留用。 一 JAVA9 新特性 1.Java Platfo...

    TigerChain 评论0 收藏0
  • 54个JAVA官方文档重要术语

    摘要:近期在阅读最新几版的官方文档过程中发现不少术语不清之处特发此文总结以下的术语大量在官方文档中直接出现且直接如基本词语一样使用不理解它们会严重影响阅读自适应自旋锁自适应自旋锁是一个允许线程在特定点自旋等待特定事件发生而不是直接进行并等待该事件 近期在阅读JAVA最新几版的官方文档过程中发现不少术语不清之处,特发此文总结.以下的术语大量在官方文档中直接出现,且直接如基本词语一样使用,不理解...

    longmon 评论0 收藏0
  • ForkJoin框架之CompletableFuture

    摘要:内部类,用于对和异常进行包装,从而保证对进行只有一次成功。是取消异常,转换后抛出。判断是否使用的线程池,在中持有该线程池的引用。 前言 近期作者对响应式编程越发感兴趣,在内部分享JAVA9-12新特性过程中,有两处特性让作者深感兴趣:1.JAVA9中的JEP266对并发编程工具的更新,包含发布订阅框架Flow和CompletableFuture加强,其中发布订阅框架以java.base...

    lindroid 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<