我打开了Java的GC日志选项


  -XX:+ PrintGC -XX:+ PrintGCTimeStamps -XX:+ PrintGC详细信息


将这些消息打印到标准输出(catalina.out):

314.884: [CMS-concurrent-mark-start]
315.014: [CMS-concurrent-mark: 0.129/0.129 secs] [Times: user=0.14 sys=0.00, real=0.13 secs]
315.014: [CMS-concurrent-preclean-start]
315.016: [CMS-concurrent-preclean: 0.003/0.003 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
315.016: [CMS-concurrent-abortable-preclean-start]
332.055: [GC 332.055: [ParNew: 17128K->84K(19136K), 0.0017700 secs] 88000K->70956K(522176K) icms_dc=4 , 0.0018660 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
 CMS: abort preclean due to time 352.253: [CMS-concurrent-abortable-preclean: 0.023/37.237 secs] [Times: user=0.78 sys=0.02, real=37.23 secs]


如何使这些日志行显示实际的时间戳(包括日期)而不是这些数字,这些数字可能意味着“自JVM启动以来的时间”?

最佳答案

据我所知这是无法完成的。根据
sun documentation

The format is not guaranteed to be the same in later releases. In particular the output associated with -XX:+PrintGCDetails is almost guaranteed to change in that it represents the current needs of JVM developers.


诚然,这是一个旧的参考(适用于Java 1.4!),但是我找不到最新的东西,而上一次我们小组进行gc调整时,几个月前,在当前的文档中没有任何关于格式化的内容。

10-01 19:34