Show TOC

Procedure documentationTracing Locate this document in the navigation structure

 

The VM does a lot of tracing, which can aid runtime analysis of Java programs. Examples are garbage collection statistics, method tracing or exception tracing.

Procedure

The verbose tracing for a certain VM component is controlled using the command line option -Xtrace in the form -Xtrace<traceflag>. Using just the option –Xtrace gives an overview of the existing trace flags.

Example Example

  • -XtraceMethods switches on the method traces.

  • -Xtrace* switches on all trace flags starting with a certain name.

    Example: -XtraceClass* switches on the following trace flags: ClassLoading, ClassUnloading, ClassStatistic

    Example: -Xtrace* switches on all trace flags.

  • -XtraceInfoHeader=<info header format>

    Each trace line is preceded by a header. This header, which is similar to a prompt line on a UNIX shell, can be freely formatted and can contain a number of useful information.

    Example: -XtraceInfoHeader=HELLO> causes the traces to look like this: HELLO> trace output.

  • -XtraceWarningHeader=<info header format>

    -XtraceErrorHeader=<info header format>

    Same as –XtraceInfoHeader for warning and error messages.

End of the example.

Placeholders can be used to embed information in the trace line. The following placeholders are available:

Placeholder

Description

@PID

Process id

@TID

Thread id

@SRC

Source file and line of the C or Java code that caused the trace output

@TIM

@TIME

Current time

@DAT

@DATE

Current date

@CMP

A short marker for the component, which caused the trace, for example, “MTH” for method traces

@VMID

Unique VM ID

Example Example

  • The command -XtraceInfoHeader=Date: @DAT(@TIM) Process:@PID Thread:@TID>> causes the traces to look like this:

    Date: 2009-01-16(15:12:48) Number:0 Process:5832 Thread:5508 >> trace output...

    Date: 2009-01-16(15:12:48) Number:1 Process:5832 Thread:5508 >> trace output...

    Date: 2009-01-16(15:12:52) Number:2 Process:5832 Thread:5508 >> trace output...

  • —XtraceWarningHeader=<info header format>

    -XtraceErrorHeader=<info header format>

    Same as –XtraceInfoHeader for warning- and error messages.

End of the example.

Below is a summary of available trace flags. As mentioned before, just use the –Xtrace command line option alone to get the full list of flags.

Trace flag syntax

Description

-XtraceFile=<file>

Write traces to the given output file.

If no file is given, output will be sent to the console. Within the NetWeaver AS Java, you will find this trace output in dev_server0 and std_server0.out in the work directory

-XtraceInfoHeader=<format>

Set the header format for info messages

-XtraceWarningHeader=<format>

Set the header format for warning messages

-XtraceErrorHeader=<format>

Set the header format for error messages

-XtraceHeader=<format>

Set the header format for all messages

-XtraceMethods

Traces each method call

-XtraceMethodsWithParameters

Traces method calls and prints their parameters

-XtraceExceptions

Traces Java exception handling

-XtraceClassLoading

Traces class loading

-XtraceClassUnloading

Traces class unloading

-XtraceJavaZipOpenClose

Traces open/close operations of zip files from Java

-XtraceJavaZipGetEntry

Traces getEntry operations of zip files from Java

-XtraceFileIoBasic

Traces basic file IO (open/close)

-XtraceFileIoBasic

Traces basic file IO (open/close)

-XtraceFileIoReadWrite

Traces file IO read and write

-XtraceNetworkIoBasic

Traces basic network operations (bind, accept, listen, ...)

-XtraceNetworkIoSendReceive

Traces send and receive network operations

-XtraceClassStatistic

Traces class statistics after full GCs

-XtraceDetailedClassStatistic

Traces detailed class statistics after full GCs

-XtraceGCStatisticLevel1

Basic GC statistic

-XtraceGCStatisticLevel2

Detailed GC statistic

-XtraceGCStatisticLevel3

Detailed GC statistic with basic information about the GC events

-XtraceGCStatisticLevel4

Detailed GC statistic with detailed information about the GC events

-XtraceGCStatisticLevel5

Detailed GC statistic with detailed information about the GC events and basic reference handling information

-XtraceGCStatisticLevel6

Detailed GC statistic with detailed information about the GC events and detailed reference handling information

-XtraceJdkInternals

Traces JDK internals

-XtraceOsDllLoad

Traces resolution/loads of shared objects

Setting trace options in a running system

In addition to the command line options, tracing settings can be changed on the fly at any time using the jvmmon tool. This allows enabling or disabling any available VM trace, therefore offering a facility to inspect problems when they occur.