Configuring log files

A context-param element in the web.xml file gives the path to the file containing the configuration for logging. The param-name attribute names the log file and the param-value attribute gives the path information. To configure logging you need to edit the log file directly. For additional information on using log4j, refer to Logging services on the Apache Foundation website.

A context-param element in the web.xml file gives the path to the file containing the configuration for logging. The param-name attribute names the log file and the param-value attribute gives the path information. To configure logging you need to edit the log file directly. For additional information on using log4j, refer to Logging services on the Apache Foundation website.

<context-param>
  <param-name>mcs.log4j.config.file</param-name>
  <param-value>[wp_root]/mcs.war/mcs-jlog.xml</param-value>
</context-param>

To configure logging you need to edit the log file directly. It contains some examples, showing how to set the priority of different categories to different levels and logging priorities to different appenders.

MCS uses the Logging Toolkit for Java (jlog) to generate log messages and trace information to the Mobile Portal Accelerator log files.

Refer to the Message Logging and Trace Information topic in the Mobile Portal Accelerator Information Center for details on where to find the log file containing the MCS log messages and the procedure to follow when making changes to mcs-jlog.xml.

Priorities

The disable attribute on the configuration takes a priority value, and disables all logging statements with a priority equal or less than this value.

fatal

Those situations where the application server, or application has to be restarted

error

Most exceptions and any other errors which do not have an exception thrown for them

warn

If a situation arises which may have been caused by the user making a mistake but where something sensible can still be done

info

Any information that the user may want to see, such as which pages have been requested, or what device is being used to render the page

debug

Trace information.

null

No priorities are disabled (default)

The same settings, with the exception of 'null' are possible for the value attribute on the priority element.

For example, to get the presentation API classes logging at 'info' priority irrespective of the disable attribute value, uncomment the following section.

<category name="com.volantis.mcs.papi">
  <priority value="info"/>
  <appender-ref ref="CONSOLE"/>
</category>

Another way to obtain information logging is to disable debug in the configuration as follows:

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
  disable="debug">

Using appenders

Appenders allow you to direct logging requests to additional output destinations. Several appenders are included in the mcs-jlog.xml file. The 'ASYNC' appender is enabled by default.

For example, if you wish to log to a socket, uncomment the appender that has 'SOCKET' in the name attribute.

<appender name="SOCKET" class="org.apache.log4j.net.SocketAppender">
  <param name="LocationInfo" value="true"/>
  <param name="RemoteHost" value="localhost"/>
  <param name="Port" value="4445"/>
  <param name="ReconnectionDelay" value="5000"/>
</appender>

You also need to uncomment or enter an appender-ref element in the root section of the file.

<appender-ref ref="SOCKET"/>

Formatting output

Log output is formatted as text by default. If you wish to produce output as XML statements edit the layout element in the relevant appender.

<layout class="org.apache.log4j.xml.XMLLayout">
  <param name="LocationInfo" value="true"/>
</layout>

Related topics