Capturing trace information (Java)

MQe does not automatically capture the trace information provided by the MQeTrace.trace() methods. The solution programmer must capture the trace messages. We strongly recommend that your solution includes a mechanism to allow the capture of MQe trace events, as this output may be requested by the IBM® service teams when investigating any problems reported.

To capture MQe trace information, you need to ensure that
  • A trace handler has been provided, and set using the MQeTrace.setHandler() method.
  • The runtime filter maintained by the MQeTrace.setFilter() method is not excluding the information you want to capture.
The required trace handler must implement the MQeTraceHandler interface. MQe ships with several trace handlers, used for different purposes:
MQeTraceToReadable
This renders trace information to a printstream in a readable format.
MQeTraceToBinaryFile
This collects trace information into a file, or sequence of files.
MQeTraceFromBinaryFile
You can use this to render this binary information file format into readable text.
MQeTraceToBinaryMidp
Collects binary trace information when running inside a MIDP Java™ environment.
   // Allocate a trace instance, so that our handler 
   // is not garbage collected when it's on.
   myMQeTrace = new MQeTrace();    
      
   // Allocate a trace handler
   // This one puts trace output to stdout by default.
   MQeTraceHandler handler = (MQeTraceHandler) 
   new com.ibm.mqe.trace.MQeTraceToReadable();
      
   // Set this handler as the one MQe uses.
   MQeTrace.setHandler(handler);
    
   // Set the filter so we collect those
   // pieces of trace we are interrested in.
   // In this case, collect all the default trace information.
   MQeTrace.setFilter(MQeTrace.GROUP_MASK_DEFAULT);

   ...

   // To end trace set the filter to zero and the handler to null
   MQeTrace.setFilter(0);
   MQeTrace.setHandler(null);  
This example shows the creation of a trace handler, MQeTraceToReadable in this case, and setting of the filter to capture the default trace information. This can result in lots of information being captured. You can use a more restrictive filter to capture only a subset of the data. For example, collecting errors, warnings, and user-coded trace points might be more appropriate:
MQeTrace.GROUP_ERROR | MQeTrace.GROUP_WARNING | MQeTrace.GROUP_MASK_USER_DEFINED
Note:
  1. The IBM Service team may ask you to use the MQeTrace.GROUP_MASK_ALL value when diagnosing a problem.
  2. When using the MQeTraceToBinaryMidp tracehandler, you require an additional step to recover the trace. The MIDP tracehandler either stores the trace in a record store or in memory. Once trace has finished, call sendDataToUrl() to recover this binary data. By default, this sends the data to a servlet. For more information, refer to the examples.trace.MQeTraceServlet section of the MQe Java Programming Reference.

Terms of use | WebSphere software

(c) Copyright IBM Corporation 2004, 2005. All rights reserved.