Tracing WebSphere MQ base Java programs
WebSphere MQ base Java includes a trace facility, which we can use to produce diagnostic messages if you suspect that there might be a problem with the code. (You normally need to use this facility only at the request of IBM service.)
Tracing is controlled by the enableTracing and disableTracing methods of the MQEnvironment class. For example:
MQEnvironment.enableTracing(2); // trace at level 2 ... // these commands will be traced MQEnvironment.disableTracing(); // turn tracing off againThe trace is written to the Java™ console (System.err).
If your program is an application, or if you run it from your local disk using the appletviewer command, we can also redirect the trace output to a file of your choice. The following code fragment shows an example of how to redirect the trace output to a file called myapp.trc:
import java.io.*; try { FileOutputStream traceFile = new FileOutputStream("myapp.trc"); MQEnvironment.enableTracing(2,traceFile); } catch (IOException ex) { // couldn't open the file, // trace to System.err instead MQEnvironment.enableTracing(2); }There are five different levels of tracing:
- Provides entry, exit, and exception tracing
- Provides parameter information in addition to 1
- Provides transmitted and received WebSphere MQ headers and data blocks in addition to 2
- Provides transmitted and received user message data in addition to 3
- Provides tracing of methods in the Java Virtual Machine in addition to 4
To trace methods in the Java Virtual Machine with trace level 5:
- For an application, run it by issuing the command java_g (instead of java)
- For an applet, run it by issuing the command appletviewer_g (instead of appletviewer)
java_g is not supported on i5/OS, but similar function is provided by using OPTION(*VERBOSE) on the RUNJVA command.
uj11410_