Adding logging and tracing to your application

You can add logging and tracing to applications to help analyze performance and diagnose problems in WebSphere® Application Server.

About this task

Deprecation: The JRas framework that is described in this information center is deprecated. However, you can achieve the same results using Java logging.

Designers and developers of applications that run with or under WebSphere Application Server, such as servlets, JavaServer Pages (JSP) files, enterprise beans, client applications, and their supporting classes, might find it useful to use Java logging for generating their application logging.

This approach has advantages over adding System.out.println statements to your code:
  • Your messages are displayed in the WebSphere Application Server standard log files, using a standard message format with additional data, such as a date and time stamp that are added automatically.
  • You can more easily correlate problems and events in your own application to problems and events that are associated with WebSphere Application Server components.
  • You can take advantage of the WebSphere Application Server log file management features.

Log handler

Procedure

  1. Enable and configure any of the supported types of logging as needed. Use one of the following methods:
  2. Customize the properties to meet your logging needs. For example, enable or disable a particular log, specify the number of logs to be kept, and specify a format for log output.
  3. If you do not want log and trace from Jakarta Commons Logging to use the WebSphere log and trace infrastructure, reconfigure the Jakarta Commons Logging.
    Best practice Best practice: Use the WebSphere log and trace infrastructure for all of your log content to make problem source identification simpler.bprac
  4. Restart the application server after making static configuration changes.

Example

The sample security policy that follows grants access to the file system and runtime classes. Include this security policy, with the entry permission java.util.logging.LoggingPermission "control", in the META-INF directory of your application if you want your applications to programmatically alter controlled properties of loggers and handlers. The META-INF file is located in the following locations for the different module types:

Project name Location
EJB projects ejbModule/META-INF/MANIFEST.MF
Application client projects appClientModule/META-INF/MANIFEST.MF
Dynamic web projects WebContent/META-INF/MANIFEST.MF
Connector projects connectorModule/META-INF/MANIFEST.MF

Below is a sample security policy that grants permission to modify logging properties:

//////////////////////////////////////////////////
//
// WebSphere Application Server Security Policy
//
//////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////
// Allow all access to the file system and runtime classes
////////////////////////////////////////////////////////////////////////
grant codeBase "file:${application}" {
   permission java.util.logging.LoggingPermission "control";
};
Task topic    

Terms and conditions for information centers | Feedback

Last updated: April 17, 2014 04:48 PM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=phil&product=was-base-iseries&topic=ttrb_addtrace
File name: ttrb_addtrace.html