如何将详细垃圾收集输出重定向到文件? [英] How to redirect verbose garbage collection output to a file?
问题描述
如何将详细垃圾收集输出重定向到文件? Sun的网站显示了一个Unix的例子,但它不适用于Windows。
-Xloggc:< file>将GC状态记录到带有时间戳的文件
记录:
-Xloggc:文件名 em>
设置文件以将日志冗长的GC事件信息重定向到该文件。写入此文件的信息类似于从每个记录的事件之前的第一个GC事件开始经过的时间,
-verbose:gc
的输出。-Xloggc
选项将覆盖-verbose:gc
,如果两者都使用相同的java
命令。
示例:
-Xloggc:垃圾收集。日志
所以输出看起来像这样:
<$ p
0.590:[GC 896K-> 278K(5056K),0.0096650秒]
0.906:[GC 1174K-> 774K(5056K),0.0106856秒]
1.320:[GC 1670K - > 1009K(5056K),0.0101132秒]
1.459:[GC 1902K-> 1055K(5056K),0.0030196秒]
1.600:[GC 1951K-> 1161K(5056K),0.0032375秒]
1.686:[GC 1805K-> 1238K(5056K),0.0034732秒]
1.690:[全GC 1238K-> 1238K(5056K),0.0631661秒]
1.874:[GC 62133K-> 61257K 65060K),0.0014464秒]
How do I redirect verbose garbage collection output to a file? Sun’s website shows an example for Unix but it doesn't work for Windows.
From the output of java -X
:
-Xloggc:<file> log GC status to a file with time stamps
Documented here:
-Xloggc:filename
Sets the file to which verbose GC events information should be redirected for logging. The information written to this file is similar to the output of
-verbose:gc
with the time elapsed since the first GC event preceding each logged event. The-Xloggc
option overrides-verbose:gc
if both are given with the samejava
command.Example:
-Xloggc:garbage-collection.log
So the output looks something like this:
0.590: [GC 896K->278K(5056K), 0.0096650 secs] 0.906: [GC 1174K->774K(5056K), 0.0106856 secs] 1.320: [GC 1670K->1009K(5056K), 0.0101132 secs] 1.459: [GC 1902K->1055K(5056K), 0.0030196 secs] 1.600: [GC 1951K->1161K(5056K), 0.0032375 secs] 1.686: [GC 1805K->1238K(5056K), 0.0034732 secs] 1.690: [Full GC 1238K->1238K(5056K), 0.0631661 secs] 1.874: [GC 62133K->61257K(65060K), 0.0014464 secs]
这篇关于如何将详细垃圾收集输出重定向到文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!