jade.util
Class Logger

java.lang.Object
  |
  +--java.util.logging.Logger
        |
        +--jade.util.Logger
All Implemented Interfaces:
java.io.Serializable, Serializable

public class Logger
extends java.util.logging.Logger
implements Serializable

This class provides a uniform API to produce logs over a set of different and device-dependent logging mechanisms. Different implementations of this class are provided according to the target environment (J2SE, pJava, MIDP), but all of them offer the same API. Finally the MIDP implementation redirects logging printouts on a MIDP RecordStore where they can be later inspected by means of the OutputViewer MIDlet distributed with the LEAP add-on.
See also this tutorial for an overview of the JADE Logging Service.
Logging levels can be used to control logging output. According to java logging philosophy, several logging levels can be set. The levels in descending order are:

SEVERE (highest value)
WARNING
INFO
CONFIG
FINE
FINER
FINEST (lowest value)

In addition, there is a level OFF that can be used to turn off logging, and a level ALL that can be used to enable logging of all messages.

Notice that re-definition of logging levels was necessary in order to allow portability of calling code in PersonalJava e MIDP environments.

For instance, in order to log the warning message "Attention!", the following code should be used, independently of the target device:

Logger logger = Logger.getMyLogger(this.getClass().getName());
if (logger.isLoggable(logger.WARNING))
logger.log(Logger.WARNING,"Attention!");

Notice that the test isLoggable allows just to improve performance, but it has no side-effect.

J2SE
The J2SE implementation is a pure extension of the java.util.logging.Logger class and it provides the whole set of functionalities of java.util.logging.

In the J2SE environment, the logging configuration can be initialized by using a logging configuration file that will be read at startup. This file is in standard java.util.Properties format. The default logging configuration, that is part of the JRE distribution, can be overridden by setting the java.util.logging.config.file system property, like the following example:
java -Djava.util.logging.config.file=mylogging.properties jade.Boot

PersonaJava
In the PJava implementation of the Logger class (available in the LEAP add-on) calls to the log() method result in calls to System.out.println(). Alternatively it is possible to redirect logging printouts to a text file by setting the -jade_util_Logger_logfile option. Note that, in order to face resource limitations, it is not possible to redirect logging printouts produced by different Logger objects to different files.

MIDP
In the MIDP implementation of the Logger class (available in the LEAP add-on) logging printouts are redirected to a MIDP RecordStore so that they can be later viewed by means of the jade.util.leap.OutputViewer MIDlet included in the LEAP add-on.

The default level for logging is set to INFO, all messages of higher level will be logged by default. In MIDP and PJava the logging level for a Logger object registererd with name x.y.z can be configured by setting the configuration option x_y_z_loglevel to one of severe, warning, info, config, fine, finer, finest, all. See the LEAP user guide for details about how to set JADE configuration options in MIDP and PJava.

Author:
Rosalba Bochicchio - TILAB, Nicolas Lhuillier - Motorola (MIDP version)
See Also:
Serialized Form

Field Summary
static java.util.logging.Level ALL
          ALL indicates that all messages should be logged.
static java.util.logging.Level CONFIG
          CONFIG is a message level for static configuration messages.
static java.util.logging.Level FINE
          FINE is a message level providing tracing information.
static java.util.logging.Level FINER
          FINER indicates a fairly detailed tracing message.
static java.util.logging.Level FINEST
          FINEST indicates a highly detailed tracing message
static java.util.logging.Level INFO
          INFO is a message level for informational messages.
static java.util.logging.Level OFF
          Special level to be used to turn off logging
static java.util.logging.Level SEVERE
          SEVERE is a message level indicating a serious failure.
static java.util.logging.Level WARNING
          WARNING is a message level indicating a potential problem.
 
Fields inherited from class java.util.logging.Logger
global
 
Method Summary
static Logger getMyLogger(java.lang.String name)
          Find or create a logger for a named subsystem.
static void initialize(Properties pp)
          Initialize the logging mechanism.
static void println(java.lang.String log)
           
 
Methods inherited from class java.util.logging.Logger
addHandler, config, entering, entering, entering, exiting, exiting, fine, finer, finest, getAnonymousLogger, getAnonymousLogger, getFilter, getHandlers, getLevel, getLogger, getLogger, getName, getParent, getResourceBundle, getResourceBundleName, getUseParentHandlers, info, isLoggable, log, log, log, log, log, logp, logp, logp, logp, logrb, logrb, logrb, logrb, removeHandler, setFilter, setLevel, setParent, setUseParentHandlers, severe, throwing, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEVERE

public static final java.util.logging.Level SEVERE
SEVERE is a message level indicating a serious failure.


WARNING

public static final java.util.logging.Level WARNING
WARNING is a message level indicating a potential problem.


INFO

public static final java.util.logging.Level INFO
INFO is a message level for informational messages.


CONFIG

public static final java.util.logging.Level CONFIG
CONFIG is a message level for static configuration messages.


FINE

public static final java.util.logging.Level FINE
FINE is a message level providing tracing information.


FINER

public static final java.util.logging.Level FINER
FINER indicates a fairly detailed tracing message.


FINEST

public static final java.util.logging.Level FINEST
FINEST indicates a highly detailed tracing message


ALL

public static final java.util.logging.Level ALL
ALL indicates that all messages should be logged.


OFF

public static final java.util.logging.Level OFF
Special level to be used to turn off logging

Method Detail

getMyLogger

public static Logger getMyLogger(java.lang.String name)
Find or create a logger for a named subsystem.

Parameters:
name - The name of the logger.
Returns:
myLogger the instance of the Logger.

initialize

public static void initialize(Properties pp)
Initialize the logging mechanism. This method makes sense only in a PJAVA or MIDP environment, but is available in J2SE too (where it does nothing) to provide a uniform interface over the different Java environments.


println

public static void println(java.lang.String log)


JADE