IBM User Guide for Java V7 on Windows > Troubleshooting and support > Using diagnostic tools > Tracing Java applications and the JVM > Using method trace
Running with method trace
Control method trace by using the command-line option -Xtrace:<option>.
To produce method trace you need to set trace options for the Javaâ„¢ classes and methods you want to trace. You also need to route the method trace to the destination you require.
You must set the following two options:
- Use -Xtrace:methods to select which Java classes and methods you want to trace.
- Use either
- -Xtrace:print to route the trace to stderr.
- -Xtrace:maximal and -Xtrace:output to route the trace to a binary compressed file using memory buffers.
Use the methods parameter to control what is traced. For example, to trace all methods on the String class, set -Xtrace:methods=java/lang/String.*,print=mt.
The methods parameter is formally defined as follows:
-Xtrace:methods=[[!]<method_spec>[,...]]Where <method_spec> is formally defined as:{*|[*]<classname>[*]}.{*|[*]<methodname>[*]}[()]Notes:
- The delimiter between parts of the package name is a forward slash, (/), even on Windows platforms where a backward slash is a path delimiter.
- The exclamation point (!) in the methods parameter is a NOT operator. You can use this symbol and multiple methods in combination. For example, the following option traces all methods in the java.util.HashMap class except those beginning with put:
-Xtrace:methods={java/util/HashMap.*,!java/util/HashMap.put*},print=mt- The parentheses, (), that are in the <method_spec> variable define whether to trace method parameters. Method call parameters are traced only for interpreted methods. If the method was compiled by the JIT compiler, the parameters are not traced.
- If a method specification includes commas, the whole specification must be enclosed in braces:
-Xtrace:methods={java/lang/*,java/util/*},print=mt
Use the print, maximal and output options to route the trace to the required destination, where:
- print formats the trace point data while the Java application is running and writes the tracepoints to stderr.
- maximal saves the trace points into memory buffers.
- output writes the memory buffers to a file, in a binary compressed format.
To produce method trace that is routed to stderr, use the print option, specifying mt (method trace). For example: -Xtrace:methods=java/lang/String.*,print=mt.
To produce method trace that is written to a binary file from the memory buffers, use the maximal and output options. For example: -Xtrace:methods=java/lang/String.*,maximal=mt,output=mytrace.trc.
If you want your trace output to contain only the tracepoints you specify, use the option -Xtrace:none to switch off the default tracepoints. For example: java -Xtrace:none -Xtrace:methods=java/lang/String.*,maximal=mt,output=mytrace.trc <class>.
Parent: Using method trace
Error 404 - Not Found Error 404 - Not Found
The document you are looking for may have been removed or re-named. Please contact the web site owner for further assistance.