Rolling garbage collector logs in java

前端 未结 6 933
孤街浪徒
孤街浪徒 2020-12-08 04:12

Is it possible to do a rolling of garbage collector logs in Sun JVM?

Currently I generate logs using:

-XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:         


        
6条回答
  •  春和景丽
    2020-12-08 04:42

    Built-in support for GC log rotation has been added to the HotSpot JVM. It is described in the RFE 6941923 and is available in:

    • Java 6 Update 34
    • Java 7 Update 2 (but there is no reference to it in these release notes)

    There are three new JVM flags that can be used to enable and configure it:

    • -XX:+UseGCLogFileRotation
      must be used with -Xloggc:;
    • -XX:NumberOfGCLogFiles=
      must be >=1, default is one;
    • -XX:GCLogFileSize=M (or K)
      default will be set to 512K.

提交回复
热议问题