log-file Configuring the Oracle CEP Logging Service

15-12 Oracle Complex Event Processing Administrators Guide This severity level applies to the module you specified in the key element and overrides the default Oracle CEP server logging severity level set in the logger-severity element that Example 15–2 shows. 5. Repeat from step 2 for any other modules. 6. Save and close the config.xml file.

15.3 Configuring Log4j Logging

Oracle CEP supports the open-source log4j logging system. This section describes the following tasks: ■ Section 15.3.1, Configuring log4j Properties ■ Section 15.3.2, Configuring Application Manifest ■ Section 15.3.3, Enabling Log4j Logging ■ Section 15.3.4, Debugging Log4j Logging For more information, see Section 15.1.3, Log4j Logger .

15.3.1 Configuring log4j Properties

The default configuration file is log4j.properties. It can be overridden by using the log4j.configuration system property. See https:www.qos.chshopproductslog4jlog4j-Manual.jsp . The following is an example of a log4j.properties file: Example 15–3 Example log4j.properties File log4j.rootLogger=debug, R log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=D:log4jlogsmywebapp.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 - mn log4j.logger=DEBUG, R

15.3.2 Configuring Application Manifest

Update the MANIFEST.MF file of your application to import the following required Log4j packages. Import-Package: org.apache.log4j;version=1.2.13, org.apache.log4j.config;version=1.2.13, ...

15.3.3 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.LogFact oryImpl Configuring Logging and Debugging for Oracle CEP 15-13 -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger -Dlog4j.configuration=URLlog4j.properties Another very useful command line property is -Dlog4j.debug=true. Use this property when log4j output fails to appear or you get cryptic error messages.

15.3.4 Debugging Log4j Logging

If log4j output fails to appear or you get cryptic error messages, consider using the command line property -Dlog4j.debug=true on the command line. For more information, see Section 15.3.3, Enabling Log4j Logging .

15.4 Using the Apache Commons Logging API

You can use Apache Commons logging API in your Oracle CEP applications to log application-specific messages to the Oracle CEP server.log and consoleoutput.log files. To use the commons logging API: 1. Set the system property org.apache.commons.logging.LogFactory to weblogic.logging.commons.LogFactoryImpl. This LogFactory creates instances of weblogic.logging.commons.LogFactoryImpl that implement the org.apache.commons.logging.Log interface. 2. From the LogFactory, get a reference to the Commons Log object by name. This name appears as the subsystem name in the log file. 3. Use the Log object to issue log requests to logging services. 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.orgcommonsloggingapiindex.html . 4. The weblogic.logging.commons.LogImpl log methods direct the message to the server log. Example 15–4 Commons Code Example import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.Log; public class MyCommonsTest { public void testCommonsLogging { System.setPropertyLogFactory.FACTORY_PROPERTY, weblogic.logging.commons.LogFactoryImpl; Log clog = LogFactory.getFactory.getInstanceMyCommonsLogger; Log String objects clog.debugHey this is common debug; clog.fatalHey this is common fatal, new Exception; clog.errorHey this is common error, new Exception; clog.traceDont leave your footprints on the sands of time; } }