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 again

The 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:

  1. Provides entry, exit, and exception tracing

  2. Provides parameter information in addition to 1

  3. Provides transmitted and received WebSphere MQ headers and data blocks in addition to 2

  4. Provides transmitted and received user message data in addition to 3

  5. 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:

java_g is not supported on i5/OS, but similar function is provided by using OPTION(*VERBOSE) on the RUNJVA command.


uj11410_