Class Logger
- java.lang.Object
-
- java.util.logging.Logger
-
- jade.util.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 thejava.util.logging.Loggerclass 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 theLoggerclass calls to thelog()method result in calls toSystem.out.println(). Alternatively it is possible to redirect logging printouts to a text file by setting the-jade_util_Logger_logfileoption. 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 theLoggerclass logging printouts are redirected to a MIDP RecordStore so that they can be later viewed by means of thejade.util.leap.OutputViewerMIDlet included in the LEAP add-on.
Android
In the Android implementation of theLoggerclass logging printouts are redirected to the Android logging system implemented by theandroid.util.Logclass.
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_loglevelto one ofsevere, 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
Fields Modifier and Type Field Description static LevelALLALL indicates that all messages should be logged.static LevelCONFIGCONFIG is a message level for static configuration messages.static LevelFINEFINE is a message level providing tracing information.static LevelFINERFINER indicates a fairly detailed tracing message.static LevelFINESTFINEST indicates a highly detailed tracing messagestatic LevelINFOINFO is a message level for informational messages.static LevelOFFSpecial level to be used to turn off loggingstatic LevelSEVERESEVERE is a message level indicating a serious failure.static LevelWARNINGWARNING is a message level indicating a potential problem.-
Fields inherited from class java.util.logging.Logger
global, GLOBAL_LOGGER_NAME
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static LoggergetJADELogger(String name)Find or create a logger for a named subsystem.static LoggergetMyLogger(String name)static voidinitialize(Properties pp)Initialize the logging mechanism.static voidprintln(String log)-
Methods inherited from class java.util.logging.Logger
addHandler, config, config, entering, entering, entering, exiting, exiting, fine, fine, finer, finer, finest, finest, getAnonymousLogger, getAnonymousLogger, getFilter, getGlobal, getHandlers, getLevel, getLogger, getLogger, getName, getParent, getResourceBundle, getResourceBundleName, getUseParentHandlers, info, info, isLoggable, log, log, log, log, log, log, log, logp, logp, logp, logp, logp, logp, logrb, logrb, logrb, logrb, logrb, logrb, logrb, logrb, removeHandler, setFilter, setLevel, setParent, setResourceBundle, setUseParentHandlers, severe, severe, throwing, warning, warning
-
-
-
-
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.
-
println
public static void println(String log)
-
-