Package jade.util

Class Logger

  • All Implemented Interfaces:
    Serializable, Serializable

    public class Logger
    extends 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 (Java Standard Edition, PersonalJava or CDC, MIDP and Android), but all of them offer the same API.
    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 environments where Java Logging is not supported.

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

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

    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 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 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.

    Android
    In the Android implementation of the Logger class logging printouts are redirected to the Android logging system implemented by the android.util.Log class.

    The default level for logging is set to INFO, all messages of higher level will be logged by default. In MIDP, PJava and Android environments, the logging level for a Logger object registered 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 Detail

      • SEVERE

        public static final Level SEVERE
        SEVERE is a message level indicating a serious failure.
      • WARNING

        public static final Level WARNING
        WARNING is a message level indicating a potential problem.
      • INFO

        public static final Level INFO
        INFO is a message level for informational messages.
      • CONFIG

        public static final Level CONFIG
        CONFIG is a message level for static configuration messages.
      • FINE

        public static final Level FINE
        FINE is a message level providing tracing information.
      • FINER

        public static final Level FINER
        FINER indicates a fairly detailed tracing message.
      • FINEST

        public static final Level FINEST
        FINEST indicates a highly detailed tracing message
      • ALL

        public static final Level ALL
        ALL indicates that all messages should be logged.
      • OFF

        public static final Level OFF
        Special level to be used to turn off logging
    • Method Detail

      • getJADELogger

        public static Logger getJADELogger​(String name)
        Find or create a logger for a named subsystem.
        Parameters:
        name - The name of the logger.
        Returns:
        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.
      • getMyLogger

        public static Logger getMyLogger​(String name)
      • println

        public static void println​(String log)