9 Configuring Logging and Tracing

This chapter describes how to configure and manage logging and tracing for Oracle Communications Services Gatekeeper.

The Services Gatekeeper trace/logging system is derived from the WebLogic logging system. For background, see ”Configuring WebLogic Logging Services” in Fusion Middleware Configuring Log Files and Filtering Log Messages for Oracle WebLogic Server.

Configuring Logging Using the Administration Console

This section explains how to change the Services Gatekeeper logging level. The default logging level is INFO. By default, error are logged to the domain_home/servers/servername/trace/default.log file.

You will select a log4j severity level during this task. See the log4j documentation for descriptions of the logging levels at the Apache web site here:

https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Level.html

To Configure Logging for a Services Gatekeeper server: 

  1. Start the Administration Console. This is the default URL:

    IP_Addr:7001/console
    

    Where IP_addr is the IP address of the system running Services Gatekeeper, and 7001 is the default port.

  2. Navigate to OCSG, then servername, then log4j, then log4j:Location=sername, logger=rootdefault

    Where servername is the name of the server you are configuring logging for.

    The Configuration and Provisioning on servername pane appears.

  3. Click Lock & Edit.

  4. Select the priority: checkbox.

  5. Enter a log severity level in the priority text field. The options are:

    • ALL

    • DEBUG

    • ERROR

    • FATAL

    • INFO

    • OFF

    • TRACE

    • WARN

  6. Click Update Attributes.

  7. Click Release Configuration.

Understanding the Trace Service

The trace service is based on Log4J. Services Gatekeeper maintains a log file, default.log, and each service instance writes to this log file on its local file system. The trace service writes log files in the domain_home/servers/server name/trace directory.

Understanding Basic Tracing

For basic tracing, the root logger rootdefault maintains the trace file.

Use these fields and methods to the TraceServiceMBean to configure and maintain basic tracing:

  • TracingEnabled field

  • attachAppender method

  • flushBuffers method

  • rollOver method

See "TraceServiceMBean Reference" for information on using this MBean.

Understanding Context Tracing

Services Gatekeeper uses context tracing to generate log messages filtered on the context of a request, for example for a certain service provider or application. This is in addition to basic tracing. A context filter has predefined filter types that define what to filter on. This enables you to trace on individual service providers, applications, and so on.

You can add new context trace files and context filters, and then apply context categories to these files to log messages from one or more Services Gatekeeper services.

To define a context trace file:

  1. In the Services Gatekeeper Administration Console, choose Container Services then TraceService.

  2. Select createContextTraceFile, or createRootContextTraceFile.

  3. For each context category to add for the context trace file, use the addContextCategory method to TraceServiceMBean

  4. For each context filter to add, use the addContextFilter method

See "TraceServiceMBean Reference" for information on using this MBean.

Log4J Hierarchies, Loggers, and Appenders

There is a set of Log4J Dynamic MBeans shipped with Services Gatekeeper that come by default with appenders. Appenders deliver LogEvents to their destination.

One Log4J hierarchy and one location are defined and displayed in the Services Gatekeeper Administration Console under Log4J as:

  • log4j:hiearchy=default,Location=AdminServer

The rootDefault logger is connected, to the default hierarchy:

  • log4j:Location=AdminServer,logger=rootDefault

You can add loggers, and add appenders to the loggers. You can change both the priority of the logger and the appender to use. You can also configure parameters for the loggers and appenders.

The set of default appenders are defined as follows:

  • log4j:appender=default,Location=AdminServer

  • log4j:appender=default,Location=AdminServer

    Note:

    The Log4J attributes are dynamic and not persisted.

To persist Log4J settings, use this configuration file:

domain_home/log4j/log4jconfig.xml

Configuring Trace for Access Tier servers

Trace configuration for network tier servers is performed through the Services Gatekeeper Administration Console by accessing Log4J for a server. For access tier servers, there are no management attributes or operations exposed in the Administration Console. This configuration must be done directly on the MBeans using a JMX-based Administration Console such as JConsole or using WLST.

For example, if you are using WLST, connect to the MBean server as described in "WebLogic Scripting Tool (WSLT)" and change to the custom tree where Services Gatekeeper MBeans are located. Change to the Log4J directory: cd('log4J').

The settings for the access tier servers can be changed in these directories:

  • log4j:appender=default

  • log4j:appender=default,layout=org.apache.log4j.TTCCLayout

  • log4j:hiearchy=default

  • log4j:logger=rootdefault

For example, to change the trace level for the access tier servers for the appender log4j:appender=default to WARN:

cd('log4j:appender=default')
set('threshold','WARN')

Using the Log4J Configuration File

In addition to using the Log4J MBeans, trace can be configured using the config.xml file a this location:

domain_home/log4j/log4jconfig.xml

The file contains an empty skeleton, by default.

The settings defined in this file are read every 30 seconds.

The ordering of the elements must be taken into account. Appenders must be declared before categories.

When using appenders that write to a file, the files are stored in domain_home.

Example Log4J Configuration file

Example 9-1 declares these appenders:

  • MyRootLogger

  • MyMultimediaMessagingWarningLogger

  • MyAccountContainerLogger

These appenders all use the same class, org.apache.log4j.FileAppender.

Each appender writes to a file whose name is given in the <param name="File" value="filename"/> element. The appenders also use the same layout class, org.apache.log4j.PatternLayout, and ConversionPattern.

The appenders are used by a set of categories, where the name attribute defines which class to trace. The categories also define which Log4J priority is logged.

In the example, the following services are logged:

  • com.bea.wlcp.wlng.account, which is the Account service.

  • com.bea.wlcp.wlng.plugin.multimediamessaging, which is the Parlay X

    Multimedia Messaging communication service.

Example 9-1 Example log4jconfig.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender name="MyRootLogger" class="org.apache.log4j.FileAppender">
<param name="File" value="A1.log"/>
<param name="Append" value="false"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%t %-5p %c{2} - %m%n"/>
</layout>    
</appender>                 
<appender name="MyMultimediaMessagingWarningLogger" class="org.apache.log4j.FileAppender">
<param name="File" value="MMS_WARN.log"/>
<param name="Append" value="false"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%t %-5p %c{2} - %m%n"/>
</layout>    
</appender>           
<appender name="MyAccountContainerLogger" class="org.apache.log4j.FileAppender">
<param name="File" value="Account.log"/>
<param name="Append" value="false"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
</layout>    
</appender>           
<category name="org.apache.log4j.xml">
<priority value="info"/>    
</category>
<!-- log for a certain service... -->
<category name="com.bea.wlcp.wlng.account">
<priority value="DEBUG"/>
<appender-ref ref="MyAccountContainerLogger"/>
</category>  
<!-- end log for a certain service... -->
<!-- log for a certain service... -->
<category name="com.bea.wlcp.wlng.plugin.multimediamessaging">
<priority value="WARN"/>
<appender-ref ref="MyMultimediaMessagingWarningLogger"/>
</category>  
<!-- end log for a certain service... -->
<root>
<priority value="debug"/>
<appender-ref ref="MyRootLogger"/>
</root>
</log4j:configuration>

TraceServiceMBean Reference

Set field values and use methods from the Administration Console by selecting Container, then Services followed by TraceService. Alternately, use a Java application. For information on the methods and fields of the supported MBeans, see the ”All Classes” section of Services Gatekeeper OAM Java API Reference.