5 Logging

This topic describes the various logging options available in Oracle JRockit and HotSpot:

Verbose Logging

Verbose logging in HotSpot can be enabled using the -verbose option. There are some specific flags that can be used with this option to get area-specific verbose output.

The following table lists various logging options available in Oracle JRockit and compares them with the options available in HotSpot:

Table 5-1 Verbose Logging

Oracle JRockit Verbose Module HotSpot Option Notes

alloc

NA

NA

class

-verbose:class

Displays information about the classes that are being loaded.

codegen

NA

NA

compaction

NA

NA

cpuinfo

NA

NA

exceptions

NA

NA

gc

-verbose:gc

Displays information about each garbage collection (GC) event.

gcheuristic

NA

NA

gcpause

NA

NA

gcpausetree

NA

NA

gcreport

NA

NA

load

NA

NA

memory

NA

NA

memdbg

NA

NA

opt

NA

NA

refobj

NA

NA

starttime

NA

NA

shutdown

NA

NA

systemgc

NA

NA

timing

NA

NA

NA

-verbose:jni

Displays information about the use of native methods and other Java Native Interface (JNI) activity.

HotSpot Logging Options

These are some of the common logging options available in HotSpot that can be used to enable the diagnostic output for a specific subsystem within the HotSpot JVM.

Table 5-2 Logging Options

HotSpot Logging Options Notes
-Xlog

Enables the common logging system for all JVM components.

-Xloggc:<filename>

Sets the file to which verbose GC event information must be redirected for logging. The information written to this file is similar to the output of -verbose:gc with the time elapsed from the first GC event preceding each logged event. The -Xloggc option overrides the -verbose:gc, if both are given with the same java command.

Note:

This option was deprecated in JDK 9.

-XX:LogFile=<path>

Sets the path and file name where the log data is written.

-XX:+LogCompilation

Enables logging of compilation activity to a file named hotspot.log in the current working directory. You can specify a different log file path and name using the -XX:LogFile option. The -XX:+LogCompilation option must be used together with the -XX:UnlockDiagnosticVMOptions option that unlocks diagnostic JVM options.

-XX:+PrintCommandLineFlags

Enables printing of the selected JVM flags that appeared on the command-line.

-XX:+PrintGC

Enables printing of messages at every GC.

Note:

This option was deprecated in JDK 9.

-XX:+PrintGCDetails

Enables printing of detailed messages at every GC.

Note:

This option was deprecated in JDK 9.

-XX:+PrintNMTStatistics

Enables printing of collected native memory tracking data at JVM exit when native memory tracking is enabled.

-XX:+PrintNMTStatistics

Enables printing of collected native memory tracking data at JVM exit when native memory tracking is enabled.

-XX:+PrintAssembly

Enables printing of assembly code resulting from JIT compilation of Java bytecode by using the external disassembler.so library. This option enables you to view the generated code, which helps you to diagnose the performance issues. This option must be used together with the -XX:UnlockDiagnosticVMOptions option that unlocks diagnostic JVM options.

-XX:+PrintCompilation

Enables verbose diagnostic output from the JVM by printing a message to the console every time a method is compiled.

-XX:+PrintInlining

Enables printing of inlining decisions. This option enables you to view the methods that are getting inlined.

-XX:+PrintClassHistogram

Enables printing of a class instance histogram after a Control+C event (SIGTERM). By default, this option is disabled.

-XX:+PrintConcurrentLocks

Enables printing of java.util.concurrent locks after a Control+C event (SIGTERM). By default, this option is disabled.

Table 5-3 GC Logging Options

GC Logging Options Notes
-Xlog:gc

Enables printing of messages at every GC. The gc is the main tag to log all GC related information. The gc tag is combined with other tags to log specific information. A few tags are listed in the following rows.

-Xlog:gc+region=trace

Enables the printing of information about the regions that are allocated and that are reclaimed by the G1 collector.

-Xlog:gc+ergo*=trace

Enables printing of information about adaptive generation sizing.

-Xlog:safepoint

Enables printing of the time elapsed from the last pause (for example, a GC pause).

-Xlog:gc+task=trace

Enables printing of time stamps for every individual GC worker thread task.

-Xlog:gc::uptime,tid

Enables printing of time stamps at every GC using the decorators uptime and tid.

-Xlog:gc+stringdedup

Prints detailed deduplication statistics.

-Xlog:gc+age=trace

Enables printing of tenuring age information.

-Xlog:gc*

Enables printing of detailed messages at every GC.

-Xlog:gc:file=<filename>

Logs messages with the gc tag to the file name specified. For example the option -Xlog:gc:file=gc.txt logs the messages to the gc.txt file.

See Enable Logging with the JVM Unified Logging Framework in the Java Platform, Standard Edition Tools Reference guide.