3.4. Configuring Logging System (monolog)

The logging system is based on Monolog, the standard API for ObjectWeb projects (refer to http://www.objectweb.org/monolog/doc/index.html). Configuring trace messages inside Jonas can be done in two ways:

NoteNote
 

The SQL requests sent to a database can be easily traced using the JOnAS Logging system and the integrated P6Spy tool. The configuration steps are described in Chapter 4 Configuring JDBC DataSources.

3.4.1. trace.properties Syntax

A standard file is provided in $JONAS_ROOT/conf/trace.properties (refer to $JONAS_BASE/conf/trace.properties). Use the CLASSPATH to retrieve this file.

The monolog documentation described in http://www.objectweb.org/monolog/doc/index.html provides more details about how to configure logging. Monolog is built over a standard log API (currently, log4j). Loggers can be defined, each one being backed on a handler.

A handler represents an output, is identified by its name, has a type, and has some additional properties. Two handlers have been defined in the trace.properties file (refer to $JONAS_BASE/conf/trace.properties):

Each handler can define the header it will use, the type of logging (console, file, rolling file), and the file name.

Note that if the tag automatic is specified as the output filename, JOnAS will replace this tag with a file pointing to $JONAS_BASE/logs/<jonas_name_server>-<timestamp>.log.

The logf handler, which is bundled with JOnAS, uses this automatic tag.

Loggers are identified by names that are structured as a tree. The root of the tree is named root.

Each logger is a topical logger (that is, it is associated with a topic). Topic names are usually based on the package name. Each logger can define the handler it will use and the trace level among the following four values:

If nothing has been defined for a logger, it will use the properties defined for its parent.

JOnAS code is written using the monolog API and can use the tty handler.

3.4.1.1. Example: Setting the DEBUG Level

To set the DEBUG level for the logger used in the jonas_ejb module:

logger.org.objectweb.jonas_ejb.level DEBUG

3.4.1.2. Example: Setting the Output Traces to the Console and a File

To set the output of JOnAS traces to both the console and a file named /tmp/jonas/log:

handler.logf.output /tmp/jonas.log
logger.org.objectweb.jonas.handler.0 tty
logger.org.objectweb.jonas.handler.1 logf

3.4.1.3. Example: Setting the Output Trace to a File

To set the output of JOnAS traces to a file in the $JONAS_BASE/logs/ directory:

handler.logf.output automatic
logger.org.objectweb.jonas.handler.0 logf