Setting up backend logging in the web.xml file in the web UI framework

The Web UI Framework allows you to enable logging for backend framework usages (Struts, mashups, and API), based on the URI for each client. Once you have specified the logging, you can activate it using the Start Request Log button in the debugging toolbar in the application.

About this task

For each logging request, the WUF backend logging will be done for the following:
  • When a Struts action is called, the Struts action name is logged.
  • When a mashup is invoked, the XAPIMashup class name and the API name/Flowname are logged.
  • When a redirect happens or requestDispatcher is created.

Procedure

  1. Use the scui-request-log-enabled context parameter of the web.xml file to set up backend logging. By default, this parameter is set to true. If it is not set to true, then the Start Request Log button does not appear.

    Sample web.xml entry:

    <context-param>
    		<param-name>scui-request-log-enabled</param-name>
     	<param-value>true</param-value> 
    </context-param>
  2. Use the com.sterlingcommerce.ui.web.framework.utils.SCUIUtils class to provide static methods to check if logging is enabled.
    public static boolean isRequestLogEnabledInCtx(SCUIContext uiContext){
            return isRequestLogEnabledInCtx(uiContext.getWebContext().getRequest());
    }
    public static boolean isRequestLogEnabledInCtx(HttpServletRequest request){
            // read from context param if enabled 
            // read from the boolean from isRequestLogEnabled
            return isRequestLogEnabledInCtx;                
    }
    ... 
    public static boolean isRequestLogEnabled(SCUIContext uiContext){
            return isRequestLogEnabled(uiContext.getWebContext().getRequest()); 
    } 
    ... 
    public
    static boolean isRequestLogEnabled(HttpServletRequest request){
            // read from context param if enabled 
            // read from the boolean from isRequestLogEnabled 
            return isRequestLogEnabled;             
    }
  3. Use the com.sterlingcommerce.ui.web.framework.context.SCUIContext class to actually log the message. The utility method in this class can be used by the application to log its request-based messages. It will be logged only if the scui-request-log-enabled context parameter is true and the user has started the request log via the debugging toolbar.
    Note: A runtime exception is thrown if the method is called when logging is not enabled by, for example, another internal method.
    ... 
    public void setRequestLogMessage(String message){
    	...
    	// check if log enabled and attribute already exists.
    	this.setAttribute(SCUIConstants.REQUEST_LOG_MSG_PARAM_NAME, message); 
    } 
    ...
  4. A separate appender is used to put all request-based logging in a separate file. The requestinfo.log file is available at <INSTALL_DIR>/logs or your default log location.

    The log has to be enabled by one of the following actions:

    • The -Dyfs.logall=Y command
    • Enabling logging via the System Management Console.

    If the log is not enabled, no logging will take place.

    Sample log message:

    2010-02-18 06:38:47,257:DEBUG  :[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)':  
    Inside SCUIAction flightTrip
    Getting Request dispatcher /stk/flightTrip/flightTrip.jsp [system]: requestlogger            
    2010-02-18 06:39:08,806:DEBUG  :[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)': 
    Inside SCUIAction getFlightTrip
    Inside SCUIXAPIMashup com.sterlingcommerce.ui.web.platform.mashup.SCUIXAPIMashup 
    Api name is getFlightTripList
    Getting Request dispatcher /stk/flightTrip/gft.jsp [stkadmin]: requestlogger            
    2010-02-18 06:39:09,013:DEBUG  :[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)': 
    Inside SCUIAction getOrganizationList
    Inside SCUIXAPIMashup com.sterlingcommerce.ui.web.platform.mashup.SCUIXAPIMashup
    Api name is getOrganizationList 
    Getting Request dispatcher /stk/flightTrip/gol.jsp [stkadmin]: requestlogger            
    2010-02-18 06:39:11,833:DEBUG  :[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)': 
    Inside SCUIAction airport 
    Getting Request dispatcher /stk/airport/airportScreen.jsp [stkadmin]: requestlogger            
    2010-02-18 06:39:15,836:DEBUG  :[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)':
    Inside SCUIAction getAirportList 
    Inside SCUIXAPIMashup com.sterlingcommerce.ui.web.platform.mashup.SCUIXAPIMashup
    Api name is getAirportList
    Getting Request dispatcher /stk/airport/airportList.jsp [stkadmin]: requestlogger            
    2010-02-18 06:39:52,948:DEBUG  :[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)':
    Inside SCUIAction activateRequestLog                        [stkadmin]: requestlogger            
  5. The Stop Request Log button comes up on the debugging toolbar when the Start Request Log button is activated. Clicking the Stop Request Log button will stop the logging in the requestinfo.log file after a final Struts action is called.