Network Deployment (Distributed operating systems), v8.0 > Troubleshoot and support
Add logging and tracing to application
Overview
Java logging has advantages over adding System.out.println statements to code...
- Add additional data, such date / time stamps
- Correlate application events to events associated with WAS components
- Leverage WAS log file management
- View messages using the Log and Trace Analyzer tool.
Procedure
- Enable and configure any of the supported types of logging as needed. Use one of the following methods:
- 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.
- 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.
Use the WebSphere log and trace infrastructure for all of your log content to make problem source identification simpler.
- 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:
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"; };
Related
Use Java logging in an application
Configure applications to use Jakarta Commons Logging
Configure Java logging