Set up for integrated JRas operation

In the integrated mode of operation, message and trace events are sent to WebSphere Application Server - Express logs. This is the default mode of operation.

  1. Import the requisite JRas extensions classes:
    import com.ibm.ras.*; 
    import com.ibm.websphere.ras.*;
    
  2. Declare logger references:
    private RASMessageLogger msgLogger = null; 
    private RASTraceLogger trcLogger = null; 
    
  3. Obtain a reference to the Manager and create the loggers.

    Since loggers are named singletons, you can do this in a variety of places. One logical candidate for servlets is the servlet init() method. For example, for the servlet named "myTestServlet", place the following code in the servlet init() method.

    com.ibm.websphere.ras.Manager mgr = com.ibm.websphere.ras.Manager.getManager(); 
    msgLogger = mgr.createRASMessageLogger("Acme", "WidgetCounter", "RasTest",
    myTestServlet.class.getName()); 
    // Configure the message logger to use the message file created for this application. 
    msgLogger.setMessageFile("acme.widgets.DefaultMessages"); 
    trcLogger = mgr.createRASTraceLogger("Acme", "Widgets", "RasTest",
    myTestServlet.class.getName); 
    mgr.addLoggerToGroup(trcLogger, groupName);