Add logging and tracing to the application

Developers of applications that run with or under WAS, such as servlets, JSP files, enterprise beans, client applications, and their supporting classes, might find it useful to use Using Java logging to generate their application logging has advantages over adding System.out.println statements to the code:

  1. To configure logging...

  2. Customize the properties to meet the 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 we 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: Use the WebSphere log and trace infrastructure for all of the log content to make problem source identification simpler.

  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 the application if you want the 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:

//////////////////////////////////////////////////
//
// WAS Security Policy //
//////////////////////////////////////////////////

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


Subtopics


Related

Configure Java logging


+

Search Tips   |   Advanced Search