本文主要研究一下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相关参数到Xlog的迁移

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.

旧版运行时参数到Xlog的迁移

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

java+jvm+log_java9 gc log参数迁移相关推荐

  1. java9 gc log参数迁移_个人文章 - SegmentFault 思否

    序 本文主要研究一下java9 gc log参数的迁移. 统一JVM及GC的Logging java9引进了一个统一的日志框架,对gc log的输出进行了统一的配置. 相关JEP(JDK Enhanc ...

  2. [Java JVM] Hotspot GC研究- 64位引用指针压缩技术

    为什么需要指针压缩 在上一篇文章 [Java JVM] Hotspot GC研究- 开篇&对象内存布局 中介绍对象内存布局时, 曾提到过, 由于在64位CPU下, 指针的宽度是64位的, 而实 ...

  3. Java JVM的17个参数

    前言 大家都知道,jvm在启动的时候,会执行默认的一些参数.一般情况下,这些设置的默认参数应对一些平常的项目也够用了.但是如果项目特别大了,需要增加一下堆内存的大小.或者是系统老是莫明的挂掉,想查看下 ...

  4. was控制台java虚拟机默认值_JVM 参数设置

    不管是YGC还是Full GC,GC过程中都会对导致程序运行中中断,正确的选择不同的GC策略,调整JVM.GC的参数,可以极大的减少由于GC工作,而导致的程序运行中断方面的问题,进而适当的提高Java ...

  5. Java JVM虚拟机参数配置 - GC

    1.堆内存 Java中的堆是JVM所管理的内存中最大的一块内存空间,主要用于存放各种类的实例对象. 在Java中堆被划分成两个不同的区域:新生代(Young).老年代(Old).而新生代又被划分为三个 ...

  6. java jvm 参数配置_Java 从小白到大牛,JVM 不得不知的一些参数和配置

    神秘的 JVM 码 有的同学虽然写了一段时间 Java 了,但是对于 JVM 却不太关注.有的同学说,参数都是团队规定好的,部署的时候也不用我动手,关注它有什么用,而且,JVM 这东西,听上去就感觉很 ...

  7. JVM从入门到精通(七):GC常用参数,Method Area,JVM调优案例分析

    GC常用参数 -Xmn -Xms -Xmx -Xss 年轻代 最小堆 最大堆 栈空间 -XX:+UseTLAB 使用TLAB,默认打开 -XX:+PrintTLAB 打印TLAB的使用情况 -XX:T ...

  8. Java中的GC(垃圾回收)log

    目录 ■启动参数 ■启动Log ■GC Log ■GC Log  ---- 垃圾回收部分 Log[Full GC] ■GC Log 对性能的影响 ■JVM 内存模型 ■GC Log  ---- 垃圾回 ...

  9. 【初级01】java JVM核心技术(1):字节码、类加载器、GC机制

    1.编程语言概述 编程语言有不同的分类方法: 面向过程.面向对象.面向函数 静态类型.动态类型 编译执行.解释执行 有虚拟机.无虚拟机 有GC.无GC Java语言是一种面向对象.静态类型.编译执行, ...

最新文章

  1. 税友报税软件让修改服务器地址,税友报税软件让修改服务器地址
  2. redis集合数据过期_如何从Redis中的集合中自动删除过期的密钥?
  3. 扩有mysql的磁盘_为提高MySQL性能而在磁盘IO方面的设置
  4. CentOS安装Mysql8各种坑。。。
  5. yoyo思维题(困难) 组合数学
  6. 【maven】dependency的systemPath属性:引入本地系统中的jar
  7. 3.2 python实战_线性回归的梯度下降法
  8. Python 中的 os 模块常见方法?
  9. 20170124L07-03-01老男孩linux运维实战培训-生产环境大于254台机器网段划分及路由解决方案案例...
  10. tensorflow-gpu_tensorflow GPU环境安装踩坑日记
  11. a标签隐藏真实地址_推荐软件:Clover(窗口标签化工具)
  12. php 自减函数,Thinkphp中某个字段值从增或自减函数
  13. E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/t
  14. 好险!一入职,就遇到MySQL这么大Bug!差点背锅走人~
  15. Django book2.0 contact表单
  16. 光盘安装服务器找不到硬盘,安装系统找不到硬盘怎么办实测解决
  17. 虹科案例 | 移动运营商:使用手持式频谱仪进行干扰检测
  18. java appkey_Java全栈工程师 风袖 appkey
  19. Java——因式分解算法
  20. VR全景,带您“飞临”探秘北京2022年冬奥会

热门文章

  1. Failed to load JavaHL Library解决方法
  2. Android 拨号器
  3. empty、isset和is_null的比较
  4. 去年一个百万级的小软件项目经验分享,20来个功能模块,项目不太好做有些棘手...
  5. 如何更新 Exchange2003 SP2 中的智能邮件筛选器版本
  6. 卫星电视巨头DISH网络接受比特币现金支付
  7. NSNotification消息通知实现源码(观察者模式原理)
  8. Oracle新一代数据库机 助所有规模企业迈向云端
  9. 阿里云linux下修改mysql默认密码(xampp环境)- 原创
  10. HDOJ How many ways?? 2157【矩阵高速幂】