WAS v8.5 > Troubleshoot > Add logging and tracing to the application > Programming with the JRas framework > Instrumenting an application with JRas extensions

JRas manager and logger instances

We can use the JRas extensions in integrated, stand-alone, or combined mode. Configuration of the application varies depending on the mode of operation, but use of the loggers to log message or trace entries is identical in all modes of operation.

Deprecated: The JRas framework described in this task and its sub-tasks is deprecated. However, we can achieve similar results using Java logging.

Integrated mode is the default mode of operation. In this mode, message and trace events are sent to the WebSphere Application Server logs.

In the combined mode, message and trace events are logged to both WAS and user-defined logs.

In the stand-alone mode, message and trace events are logged only to user-defined logs.


Use the message and trace loggers

Regardless of the mode of operation, the use of message and trace loggers is the same.


Use a message logger

The message logger is configured to use the DefaultMessages resource bundle. Message keys must be passed to the message loggers if the loggers are using the message API.

msgLogger.message(RASIMessageEvent.TYPE_WARNING, this, 
     methodName, "MSG_KEY_00");
... msgLogger.message(RASIMessageEvent.TYPE_WARN, this, 
     methodName, "MSG_KEY_01", "some string");

If message loggers use the msg API, we can specify a new resource bundle name.

msgLogger.msg(RASIMessageEvent.TYPE_ERR, this, methodName, 
                  "ALT_MSG_KEY_00", "alternateMessageFile");

We can also log a text message. If we are using the textMessage API, no message formatting is done.

msgLogger.textMessage(RASIMessageEvent.TYPE_INFO, this, methodName,"String and Integer", 
"A String", new Integer(5)); 


Use a trace logger

Because trace is normally disabled, guard trace methods for performance reasons.

private void methodX(int x, String y, Foo z) 
{ 
   // trace an entry point. Use the guard to make sure tracing is enabled. 
Do this checking before you gather parameters to  trace. 
   if (trcLogger.isLoggable(RASITraceEvent.TYPE_ENTRY_EXIT) { 
        // I want to trace three parameters, package them up in an Object[] 
        Object[] parms = {new Integer(x), y, z}; 
        trcLogger.entry(RASITraceEvent.TYPE_ENTRY_EXIT, this, "methodX", parms); 
  } 
... logic 
  // a debug or verbose trace point 
  if (trcLogger.isLoggable(RASITraceEvent.TYPE_MISC_DATA) { 
        trcLogger.trace(RASITraceEvent.TYPE_MISC_DATA, this, "methodX" "reached here"); 
  } 
  ... 
  // Another classification of trace event. An important state change is 
 detected, so a different trace type is used. 
  if (trcLogger.isLoggable(RASITraceEvent.TYPE_SVC) { 
     trcLogger.trace(RASITraceEvent.TYPE_SVC, this, "methodX", "an important event"); 
  } 
 ... 
  // ready to exit method, trace. No return value to trace 
    if (trcLogger.isLoggable(RASITraceEvent.TYPE_ENTRY_EXIT)) { 
        trcLogger.exit(RASITraceEvent.TYPE_ENTRY_EXIT, this, "methodX"); 
   } } 


Related


Set up for integrated JRas operation
Set up for combined JRas operation
Set up for stand-alone JRas operation
Create JRas resource bundles and message files


+

Search Tips   |   Advanced Search