13 Managing and Configuring the Trace Service

This chapter describes how to configure and manage the Trace service in Oracle Communications Services Gatekeeper.

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

Context tracing generates log messages filtered on the context of a request such as, for a certain service provider or application, in addition to basic tracing. Context trace filters narrow the generated log messages to requests that match a given context filter. A context filter has predefined filter types that define what to filter on. For a given filter type, the value to match is defined. This is used for tracing on individual service providers, applications, and so on.

New context trace files can be added, and context filters and context categories can be applied to these files. Context categories can be added to the context trace file to log messages from one or more Services Gatekeeper services. For example, to log messages from the Budget service and the Short Message Peer-to-Peer Protocol (SMPP) plug-in to a context trace file, the context categories for these services are added to the context trace file.

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 inforamtion 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 are responsible for delivering 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 the 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 the following 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 file:

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

Following is an example where the following named appenders are declared:

  • MyRootLogger

  • MyMultimediaMessagingWarningLogger

  • MyAccountContainerLogger

All these appenders use the same class, org.apache.log4j.FileAppender.

Each appender writes to a file whose name is given in the <param name="File" value="<File name>"/> 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 that shall be 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 13-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.