Administration and Configuration Guide

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Configuring Logging and Debugging

This section contains information on the following subjects:

 


Configuration Scenarios

System administrators and developers configure logging output and filter log messages to troubleshoot errors or to receive notification for specific events.

The following tasks describe some logging configuration scenarios:

 


Overview of Logging Services Configuration

This release provides a commons-logging interface. The interface provides commons.logging.LogFactory and Log interface implementations. It includes an extension of the org.apache.commons.logging.LogFactory class that acts as a factory to create an implementation of the org.apache.commons.logging.Log that delegates to the LoggingService in the logging module. The name of this default implementation is weblogic.logging.commons.LogFactoryImpl.

See http://jakarta.apache.org/commons/logging/apidocs/index.html.

Setting the Log Factory

The following provides information on setting the log factory using system properties:

Using Log Severity Levels

Each log message has an associated severity level. The level gives a rough guide to the importance and urgency of a log message. Predefined severities, ranging from TRACE to EMERGENCY, are converted to a log level when dispatching a log request to the logger. A log level object can specify any of the following values, from lowest to highest impact:

   TRACE, DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL, ALERT, EMERGENCY

You can set a log severity level on the logger, the handler, and a user application. When set on the logger, none of the handlers receive an event which is rejected by the logger. For example, if you set the log level to NOTICE on the logger, none of the handlers will receive INFO level events. When you set a log level on the handler, the restriction only applies to that handler and not the others. For example, turning DEBUG off for the File Handler means no DEBUG messages will be written to the log file, however, DEBUG messages will be written to standard out.

Users (Oracle CEP module owners or owners of user applications) are free to define the names that represent the logging category type used by the Apache commons logging for individual modules. However if the category names are defined as package names then based on the naming convention, a logging level hierarchy is assumed by default. For example, if two modules name their logging category names com.oracle.foo and com.oracle.foo.bar, then com.oracle.foo becomes the root node of com.oracle.foo.bar. This way any logging level applied to parent node (com.oracle.foo) automatically applies to com.oracle.foo.bar, unless the child node overrides the parent.

In other words, if the logging severity is specified for a node, it is effective unless the severity is inherited from the nearest parent whose severity is explicitly configured. The root node is always explicitly configured, so if nothing else if set, then all the nodes inherit the severity from the root.

Table 12-1 lists the severity levels of log messages.

Table 12-1 Message Severity 
Severity
Meaning
TRACE
Used for messages from the Diagnostic Action Library. Upon enabling diagnostic instrumentation of server and application classes, TRACE messages follow the request path of a method.
DEBUG
A debug message was generated.
INFO
Used for reporting normal operations, a low-level informational message.
NOTICE
An informational message with a higher level of importance.
WARNING
A suspicious operation or configuration has occurred but it might not affect normal operation.
ERROR
A user error has occurred. The system or application can handle the error with no interruption and limited degradation of service.
CRITICAL
A system or service error has occurred. The system can recover but there might be a momentary loss or permanent degradation of service.
ALERT
A particular service is in an unusable state while other parts of the system continue to function. Automatic recovery is not possible; the immediate attention of the administrator is needed to resolve the problem.
EMERGENCY
The server is in an unusable state. This severity indicates a severe system failure or panic.

The system generates many messages of lower severity and fewer messages of higher severity. For example, under normal circumstances, they generate many INFO messages and no EMERGENCY messages.

Log Message Format

The system writes a message to sdtout and the specified log file, consisting of the Timestamp, Severity, Subsystem, and the Message, along with the stacktrace if any. Each attribute is contained between angle brackets.

The following is an example of a message in the server log file:

<May 02, 2007 10:46:51 AM EST> <Notice> <CommonTestSubsystem> <BEA-123456> 
<Another Commons test message>

Format of Output to Standard Out and Standard Error

When the system writes a message to standard out, the output does not include the #### prefix and does not include the Server Name, Machine Name, Thread ID, User ID, Transaction ID, Diagnostic Context ID, and Raw Time Value fields.

The following is an example of how the message from the previous section would be printed to standard out:

<Sept 22, 2004 10:51:10 AM EST> <Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>

In this example, the message attributes are: Locale-formatted Timestamp, Severity, Subsystem, Message ID, and Message Text.

OSGI Framework Logger

Oracle CEP has a low-level framework logger that is started before the OSGi framework. It is used to report logging event deep inside the OSGi framework and function as a custom default for the logging subsystem before it is configured.

For example, a user may see some log message, which has lower level or severity than what is set in the config.xml but higher or equal to what is set on the Launcher command line on the console or in the log file. Until the logging subsystem has started, log messages come from the framework logger and use the framework logging level to filter messages.

 


How to Use the Commons Logging API

To use Commons Logging:

  1. Set the system property org.apache.commons.logging.LogFactory to weblogic.logging.commons.LogFactoryImpl.
  2. This LogFactory creates instances of weblogic.logging.commons.LogFactoryImpl that implement the org.apache.commons.logging.Log interface.

  3. From the LogFactory, get a reference to the Commons Log object by name.
  4. This name appears as the subsystem name in the log file.

  5. Use the Log object to issue log requests to logging services.
  6. The Commons Log interface methods accept an object. In most cases, this will be a string containing the message text.

    The Commons LogObject takes a message ID, subsystem name, and a string message argument in its constructor. See org.apache.commons.logging at http://jakarta.apache.org/commons/logging/api/index.html.

  7. The weblogic.logging.commons.LogImpl log methods direct the message to the server log.
  8. Listing 12-1 Commons Code Example
    import org.apache.commons.logging.LogFactory;
    import org.apache.commons.logging.Log;
    public class MyCommonsTest {
      public void testCommonsLogging() {
        System.setProperty(LogFactory.FACTORY_PROPERTY,
          "weblogic.logging.commons.LogFactoryImpl");
        Log clog = LogFactory.getFactory().getInstance("MyCommonsLogger");
        // Log String objects
        clog.debug("Hey this is common debug");
        clog.fatal("Hey this is common fatal", new Exception());
        clog.error("Hey this is common error", new Exception());
        clog.trace("Dont leave your footprints on the sands of time");
      }
    }

 


Configuring the Oracle CEP Logging Service

The following sections provide information on configuring Oracle CEP logging:

logging-service

This section provides information on the <logging-service> configuration object:

Table 12-2 Configuration Parameters for <logging-service>
Parameter
Type
Description
log-file-config
String
The configuration of the log file and its rotation policies.
See log-file.
stdout-config
String
The name of the stdout configuration object used to configure stdout output. See log-stdout.

logger-severity

String
Defines the threshold importance of the messages that are propagated to the handlers.
The default value is Info. To see Debug and Trace messages, configure the logger-severity to either Debug or Trace. Valid values are: Emergency, Alert, Critical, Error, Warning, Notice, Info, Debug, Trace.
name
String
The name of this configuration object.
logger-severity-properties
One or more <entry> child elements.
List of name-value pairs, enclosed in an <entry> element, that list individual modules and their logging severity. These severities override the default severity of the Oracle CEP server.

log-stdout

This section provides information on the log-stdout configuration object:

Table 12-3 Configuration Parameters for log-stdout
Parameter
Type
Description
stack-trace-depth
Integer
The number of stack trace frames to display on stdout.
A default value of -1 means all frames are displayed.
stack-trace-enabled
Boolean
If true, stack traces are dumped to the console when included in logged messages. Default value is true.
stdout-severity
String
The threshold severity for messages sent to stdout. Default value is Notice.

Valid values are: Emergency, Alert, Critical, Error, Warning, Notice, Info, Debug, Trace.

name
String
The name of this configuration object.

log-file

This section provides information on the log-file configuration object:

Table 12-4 Configuration Parameters for log-file
Parameter
Type
Description
number-of-files-limited
Boolean
If true, old rotated files are deleted. Default is false.
rotation-type
String
Specifies how rotation is performed based on size, time, or not at all.

Valid values are: bySize, byTime, none.

rotation-time
String
The time in k:mm format, where k is the hour specified in 24 hour notation and mm is the minutes.
Default is 00:00
rotation-time-span-factor
Long
Factor applied to the timespan to determine the number of milliseconds that becomes the frequency of time based log rotations. Default is 3600000.
rotated-file-count
Integer
Specifies the number of old rotated files to keep if number-of-files-limited is true. Default value is 7.
rotation-size
Integer
The size threshold, in KB, at which the log file is rotated. Default is 500.
rotation-time-span
Integer
Specifies the interval for every time-based log rotation. Default value is 24.
base-log-file-name
String
The log file name. Default value is server.log.
rotate-log-on-startup-enabled
Boolean
If true, the log file is rotated on startup. Default value is true.
log-file-severity
String
Specifies the least important severity of messages written to the log file. Default value is Trace.
Valid values are: Emergency, Alert, Critical, Error, Warning, Notice, Info, Debug, Trace.
log-file-rotation-dir
String

Specifies the directory where old rotated files are stored.

If not set, the old files are stored in the same directory as the base log file.

name
String
The name of this configuration object.

Configuring Severity for an Individual Module

Individual modules of Oracle CEP can specify their logging severity. This severity overrides the default logging severity of Oracle CEP, which is Notice. You do this by specifying the name of the module package and its logging severity as <logger-severity-properties> element within the log configuration in the server’s config.xml file. Multiple packages or loggers can be specified in the <logger-severity-properties> element as name value pairs.

The following sample config.xml shows how to change the logging severity for a number of modules of Oracle CEP:

  <logging-service>
<name>myLogService</name>
<logger-severity>Warning</logger-severity>
<logger-severity-properties>
<entry>
<key>com.bea.wlevs.ede</key>
<value>Debug</value>
</entry>
<entry>
<key>sample.HelloWorld</key>
<value>Debug</value>
</entry>
<entry>
<key>com.bea.wlevs.cep.core.EPRuntimeImpl</key>
<value>Debug</value>
</entry>
</logger-severity-properties>
<stdout-config>myStdoutConfig</stdout-config>
<log-file-config>myLogFileConfig</log-file-config>
</logging-service>

In the example, the default logging severity for the server is WARNING. However, the logging severity for any modules in the com.bea.wlevs.ede package, the sample.HelloWorld user application, and the com.bea.wlevs.cep.core.EPRuntimeImpl class is DEBUG.

 


Debug

The following sections provide information on how to use the Oracle CEP debugging feature:

Configuring debug using System Properties

You can set a system property on the Java command line by using the following steps:

  1. Create a property by prepending -D to the flag
  2. Turn the flag on by setting the property to true.

For example: -Dcom.bea.core.debug.DebugSDS=true

Configuring debug using a Configuration File

Use the following steps to configure debugging from a configuration file:

  1. Create an XML tag by dropping “com.bea.core.debug.” from the flag name.
  2. Turn the flag on by setting the flag to true.
  3. Wrap with debug-properties tag.
  4. Set logger-severity to Debug in the logging service stanza.
  5. Set stdout-severity to Debug in the stdout configuration stanza.

See Example Debug Configuration.

Supported Debug Flags

The following table provides the supported debug flags for this release:

Table 12-5 Debug Flags
Debug Flag
Description
com.bea.core.debug.DebugSDS
Simple Declarative Services
com.bea.core.debug.DebugSDS.stdout
SDS debug strings go to stdout

com.bea.core.debug.DebugServiceHelper

Service Helper
com.bea.core.debug.DebugServiceHelper.stdout
Service Helper debug strings go to stdout
com.bea.core.debug.servicehelper.dumpstack
Dump stack traces when Service Helper times out.
com.bea.core.debug.DebugSCP
Simple Configuration Provider
com.bea.core.debug.DebugSCP.stdout
Simple Configuration Provider debug strings go to stdout
com.bea.core.debug.DebugCM
Configuration Manager
com.bea.core.debug.DebugCM.stdout
Configuration Manager debug strings go to stdout
com.bea.core.debug.DebugCSSServices
CSS Services
com.bea.core.debug.DebugCSSServices.stdout
CSS Services debug strings go to stdout
com.bea.core.debug.DebugCSS
CSS
com.bea.core.debug.DebugCSS.stdout
CSS debug strings go to stdout
com.bea.core.debug.DebugBootBundle
Boot Debugging
com.bea.core.debug.DebugBootBundle.stdout
Boot Debugging debug strings go to stdout
com.bea.core.debug.DebugJTA2PC
JTA 2PC
com.bea.core.debug.DebugJTA2PCDetail
JTA 2PCDetail
com.bea.core.debug.DebugJTA2PCStackTrace
JTA 2PCStackTrace
com.bea.core.debug.DebugJTAGateway
JTA Gateway
com.bea.core.debug.DebugJTAGatewayStackTrace
JTA GatewayStackTrace
com.bea.core.debug.DebugJTAHealth
JTA Health
com.bea.core.debug.DebugJTALifecycle
JTA Lifecycle
com.bea.core.debug.DebugJTALLR
JTA LLR
com.bea.core.debug.DebugJTAMigration
JTA Migration
com.bea.core.debug.DebugJTANaming
JTA Naming
com.bea.core.debug.DebugJTANamingStackTrace
JTA NamingStackTrace
com.bea.core.debug.DebugJTANonXA
JTA NonXA
com.bea.core.debug.DebugJTAPropagate
JTA Propagate
com.bea.core.debug.DebugJTARecovery
JTA Recovery
com.bea.core.debug.DebugJTAResourceHealth
JTA ResourceHealth
com.bea.core.debug.DebugJTATLOG
JTA TLOG
com.bea.core.debug.DebugJTAXA
JTA XA
com.bea.core.debug.DebugJTAXAStackTrace
JTA XAStackTrace
com.bea.core.debug.DebugStoreAdmin
Store Administration
com.bea.core.debug.DebugStoreIOPhysical
Store IOPhysical
com.bea.core.debug.DebugStoreIOPhysicalVerbose
Store IOPhysicalVerbose
com.bea.core.debug.DebugStoreIOLogical
Store IOLogical
com.bea.core.debug.DebugStoreIOLogicalBoot
Store IOLogicalBoot
com.bea.core.debug.DebugStoreXA
Store XA
com.bea.core.debug.DebugStoreXAVerbose
Store XAVerbose
com.bea.core.debug.DebugConfigurationRuntime
Runtime information from the Runtime MBeans
com.bea.core.debug.DebugJDBCInternal
JDBC Internal
com.bea.core.debug.DebugJTAJDBC
JTA JDBC
com.bea.core.debug.DebugJDBCSQL
JDBC SQL
com.bea.core.debug.DebugJDBCRMI
JDBC RMI
com.bea.core.debug.DebugJDBCConn
JDBC Connection
com.bea.core.debug.DebugNetIO
NetIO
com.bea.core.debug.DebugOX
OSGi to JMX (OX)
com.bea.core.debug.DebugOX.stdout
OSGi to JMX (OX), debug goes to stdout

Example Debug Configuration

The following code provides an example debug configuration to turn on Simple Declarative Services (SDS) debugging in the config.xml file:

Listing 12-2 Example debug Configuration
<config>
   <debug>
      <debug-properties>
         <DebugSDS>true</DebugSDS>
      </debug-properties>
   </debug>

   <logging-service>
      <logger-severity>Debug</logger-severity>
      <stdout-config>logStdout</stdout-config>
      <log-file-config>logFile</log-file-config>
   </logging-service>

   <log-file>
   <name>logFile</name>
   <log-file-severity>Debug</log-file-severity>
   <number-of-files-limited>true</number-of-files-limited>
   <rotated-file-count>4</rotated-file-count>
   <rotate-log-on-startup-enabled>true</rotate-log-on-startup-enabled>
   </log-file>

   <log-stdout>
      <name>logStdout</name>
      <stdout-severity>Debug</stdout-severity>
   </log-stdout>
</config>

 


Log4j

The following sections provide information on using Log4j:

About Log4j

Log4j is an open source tool developed for putting log statements in your application. Log4j has three main components:

The Log4j Java logging facility was developed by the Jakarta Project of the Apache Foundation. See:

Loggers

Log4j defines a Logger class. An application can create multiple loggers, each with a unique name. In a typical usage of Log4j, an application creates a Logger instance for each application class that will emit log messages. Loggers exist in a namespace hierarchy and inherit behavior from their ancestors in the hierarchy.

Appenders

Log4j defines appenders (handlers) to represent destinations for logging output. Multiple appenders can be defined. For example, an application might define an appender that sends log messages to standard out, and another appender that writes log messages to a file. Individual loggers might be configured to write to zero or more appenders. One example usage would be to send all logging messages (all levels) to a log file, but only ERROR level messages to standard out.

Layouts

Log4j defines layouts to control the format of log messages. Each layout specifies a particular message format. A specific layout is associated with each appender. This lets you specify a different log message format for standard out than for file output, for example.

log4j Properties

The default configuration file is log4j.properties. It can be overridden by using the log4j.configuration system property. See https://www.qos.ch/shop/products/log4j/log4j-Manual.jsp.

The following is an example of a log4j.properties file:

Listing 12-3 Example log4j.properties File
   log4j.rootLogger=debug, R 
   log4j.appender.R=org.apache.log4j.RollingFileAppender
   log4j.appender.R.File=D:/log4j/logs/mywebapp.log
   log4j.appender.R.MaxFileSize=10MB
   log4j.appender.R.MaxBackupIndex=10
   log4j.appender.R.layout=org.apache.log4j.PatternLayout
   log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
   log4j.logger=DEBUG, R

Enabling Log4j Logging

To specify logging to a Log4j Logger, set the following system properties on the command line:

   -Dorg.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryimpl
   -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
   -Dlog4j.configuration=<URL>/log4j.properties

  Back to Top       Previous  Next