Tracing in the Java code base is performed using the com.ibm.mqe.MQeTrace class
. All calls to com.ibm.mqe.MQeTrace.trace()
methods pass the following information:
- A number, by which the trace point can be identified.
- A group bit-mask, which identifies this trace point as being classified as part of one or more groups of trace points. This information is used with the MQeTrace.setFilter() method, to allow unwanted trace information to be filtered out at runtime. Many of the bits in the group bit-mask have a defined meaning. For example, if the MQeTrace.GROUP_ERROR bit is set, then the trace point indicates that an error is being reported. Multiple group bits can be set for the same trace point.
- A number of parameters. A tostring() method is invoked for each parameter, so that a string is extracted at runtime and added to the trace point.
Classes shipped in MQe generate lots of trace information using these methods, such that the trace point numbers are all negative. We recommend that programs using this trace mechanism use positive numbers or zero.
Several bit fields are reserved for user applications, for example, the MQeTrace.GROUP_MASK_USER_DEFINED
bit fields. For convenience, MQeTrace.GROUP_USER_DEFINED_1
maps to one such bit, for example:
MQeTrace.trace(this, (short) 1, MQeTrace.GROUP_ERROR |
MQeTrace.GROUP_USER_DEFINED_1, thingToLog );
This statement implements a logical AND
operation on the GROUP_ERROR
, maintaining the runtime filter with the MQeTrace
class. If the result is non-zero, then the corresponding method on the MQeTraceHandler
interface class is called if a handler has been set.
There are several variants of the MQeTrace.trace()
method, including methods that trace different numbers of parameters with the trace point.
Parent topic: Tracing and logging with Java: XPD622