How to redirect verbose garbage collection output to a file?

后端 未结 4 1082
轮回少年
轮回少年 2020-12-02 08:32

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.

4条回答
  •  醉梦人生
    2020-12-02 09:03

    To add to the above answers, there's a good article: Useful JVM Flags – Part 8 (GC Logging) by Patrick Peschlow.

    A brief excerpt:

    The flag -XX:+PrintGC (or the alias -verbose:gc) activates the “simple” GC logging mode

    By default the GC log is written to stdout. With -Xloggc: we may instead specify an output file. Note that this flag implicitly sets -XX:+PrintGC and -XX:+PrintGCTimeStamps as well.

    If we use -XX:+PrintGCDetails instead of -XX:+PrintGC, we activate the “detailed” GC logging mode which differs depending on the GC algorithm used.

    With -XX:+PrintGCTimeStamps a timestamp reflecting the real time passed in seconds since JVM start is added to every line.

    If we specify -XX:+PrintGCDateStamps each line starts with the absolute date and time.

提交回复
热议问题