问题描述
如何将详细垃圾回收输出重定向到文件?Sun 的网站显示了一个适用于 Unix 的示例,但它不适用于 Windows.
来自java -X
的输出:
记录在这里:
<块引用>-Xloggc:文件名
设置详细的 GC 事件信息应重定向到的文件以进行日志记录.写入此文件的信息类似于 -verbose:gc
的输出,其中包含自每个记录事件之前的第一个 GC 事件以来经过的时间.-Xloggc
选项覆盖 -verbose:gc
如果两者都使用相同的 java
命令.
例子:
-Xloggc:garbage-collection.log
所以输出看起来像这样:
<上一页>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]
这篇关于如何将详细的垃圾收集输出重定向到文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!