Java Garbage Collection Logging

From NovaOrdis Knowledge Base
Revision as of 03:40, 13 February 2017 by Ovidiu (talk | contribs) (→‎-Xloggc:)
Jump to navigation Jump to search

Internal

Command Line Options

Java 8

https://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html#BABFAFAE

Overview

In Java 8, GC logging is enabled with the -Xloggc:<file> (see below). The actual -XX values the JVM operates with are displayed at the top of the log file:

...
CommandLine flags: -XX:InitialHeapSize=268435456 -XX:MaxHeapSize=4294967296 -XX:+PrintGC -XX:+PrintGCTimeStamps -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseParallelGC
...

Options

-Xloggc:

Turns on GC logging and directs the output into the specified file. When used, -verbose:gc becomes irrelevant.

-Xloggc:<file>

where <file> can be absolute or relative. In case of a relative path, it is relative to the current directory.

If used, the option automatically turns on the following: -XX:+PrintGC, -XX:+PrintGCTimeStamps.

-XX:+PrintGC

-XX:+PrintGC

Enables printing of messages at every GC. By default, this option is disabled, but -Xloggc:<file> turns it on implicitly.

-XX:+PrintGCTimeStamps

-XX:+PrintGCTimeStamps

Enables printing of time stamps (time in seconds since the JVM started) at every GC. By default, this option is disabled. It is implicit turned on if -Xloggc:<file> is used. Time stamps recorded this way provide a chronology relative to the time the JVM started, but additional calculation is needed to translate the timestamps to normal timestamps, and it is only possible if the JVM start time is also recorded. A better way to record timestamps is to use -XX:+PrintGCDateStamps.

-XX:+PrintGCDateStamps

-XX:+PrintGCDateStamps

Records the GC event timestamps in the following format:

2017-02-12T19:26:03.328+0800:




-verbose:gc
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=5
-XX:GCLogFileSize=3M

-verbose:gc

Displays GC log information at stdout. This option is rendered irrelevant by -Xloggc:<file>. When -Xloggc:<file> is used, the GC log information is redirected into the specified file.

Options That Do Not Seem to Have Any Effect