在 java 9 中处理 PrintGCApplicationStoppedTime 标志
Handle PrintGCApplicationStoppedTime flag in java 9
我的应用程序正在使用 gc 标志 "PrintGCApplicationStoppedTime",但是当 运行 它带有 Java 9 时,它失败并出现以下错误:
Unrecognized VM option 'PrintGCApplicationStoppedTime'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
This post 表示该选项已弃用,但是否有任何替代他的标志打印的信息或此信息不再可用?
需要知道的几件事:
先好了回答 by @apangin sums up quite well that the PrintGCApplicationStoppedTime
prints the time spent inside safepoints.
为了将更多细节转储到应用程序的安全点上,您最好使用:
-XX:+PrintSafepointStatistics -XX:PrintSafepointStatisticsCount=1
二、Java9个计划实施Unified GC logging under JEP#271 which at the same time would make use of the Unified JVM Logging under JEP#158
展望未来,-Xlog
将用作新的命令行选项来控制来自 JVM 所有组件的日志记录。因此,日志记录将遵循语法(引用):
-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
挑选几个不同的例子来学习的地方是:
-Xlog:gc=trace:file=gctrace.txt:uptimemillis,pids:filecount=5,filesize=1024
- 使用 'trace' 级别记录带有 'gc' 标签的消息
一个旋转文件集,包含 5 个文件,大小为 1MB,基本名称
'gctrace.txt' 并使用装饰 'uptimemillis' 和 'pid'
- 'warning' 到 'stderr' 级别的所有消息的默认输出
仍然有效
-Xlog:gc+rt+compiler*=debug,meta*=warning,svc*=off
- 记录至少带有 'gc'、'rt' 和 'compiler' 标记的消息
使用 'trace' 级别到 'stdout' 但仅记录标记的消息
with 'meta' with level 'warning' or 'error' 并关闭所有
带有 'svc'
标记的邮件
- 'warning' 到 'stderr' 级别的所有消息的默认输出
仍然有效
另请参阅 JDK 9 发行说明,其中详细介绍了统一日志记录 (-Xlog) 的含义:
http://jdk.java.net/9/release-notes#JDK-8145092
您会看到 PrintGCApplicationStoppedTime 和几个选项已被删除。
我的应用程序正在使用 gc 标志 "PrintGCApplicationStoppedTime",但是当 运行 它带有 Java 9 时,它失败并出现以下错误:
Unrecognized VM option 'PrintGCApplicationStoppedTime'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
This post 表示该选项已弃用,但是否有任何替代他的标志打印的信息或此信息不再可用?
需要知道的几件事:
先好了回答PrintGCApplicationStoppedTime
prints the time spent inside safepoints.
为了将更多细节转储到应用程序的安全点上,您最好使用:
-XX:+PrintSafepointStatistics -XX:PrintSafepointStatisticsCount=1
二、Java9个计划实施Unified GC logging under JEP#271 which at the same time would make use of the Unified JVM Logging under JEP#158
展望未来,-Xlog
将用作新的命令行选项来控制来自 JVM 所有组件的日志记录。因此,日志记录将遵循语法(引用):
-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
挑选几个不同的例子来学习的地方是:
-Xlog:gc=trace:file=gctrace.txt:uptimemillis,pids:filecount=5,filesize=1024
- 使用 'trace' 级别记录带有 'gc' 标签的消息 一个旋转文件集,包含 5 个文件,大小为 1MB,基本名称 'gctrace.txt' 并使用装饰 'uptimemillis' 和 'pid'
- 'warning' 到 'stderr' 级别的所有消息的默认输出 仍然有效
-Xlog:gc+rt+compiler*=debug,meta*=warning,svc*=off
- 记录至少带有 'gc'、'rt' 和 'compiler' 标记的消息 使用 'trace' 级别到 'stdout' 但仅记录标记的消息 with 'meta' with level 'warning' or 'error' 并关闭所有 带有 'svc' 标记的邮件
- 'warning' 到 'stderr' 级别的所有消息的默认输出 仍然有效
另请参阅 JDK 9 发行说明,其中详细介绍了统一日志记录 (-Xlog) 的含义: http://jdk.java.net/9/release-notes#JDK-8145092 您会看到 PrintGCApplicationStoppedTime 和几个选项已被删除。