public class Logger extends Logger implements Serializable
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.
Modifier and Type | Class and Description |
---|---|
private static class |
Logger.DummyLogger |
private static class |
Logger.LoggerWrapper
Inner class LoggerWrapper
|
Modifier and Type | Field and Description |
---|---|
static Level |
ALL
ALL indicates that all messages should be logged.
|
static Level |
CONFIG
CONFIG is a message level for static configuration messages.
|
static Level |
FINE
FINE is a message level providing tracing information.
|
static Level |
FINER
FINER indicates a fairly detailed tracing message.
|
static Level |
FINEST
FINEST indicates a highly detailed tracing message
|
static Level |
INFO
INFO is a message level for informational messages.
|
private static PrintStream |
logStream |
static Level |
OFF
Special level to be used to turn off logging
|
static Level |
SEVERE
SEVERE is a message level indicating a serious failure.
|
static Level |
WARNING
WARNING is a message level indicating a potential problem.
|
private static Map |
wrappers |
global, GLOBAL_LOGGER_NAME
Modifier | Constructor and Description |
---|---|
private |
Logger(String name,
String resourceBundleName)
Private method to construct a logger for a named subsystem.
|
Modifier and Type | Method and Description |
---|---|
static Logger |
getMyLogger(String name)
Find or create a logger for a named subsystem.
|
private static Logger |
getWrapper(Logger lg) |
static void |
initialize(Properties pp)
Initialize the logging mechanism.
|
static void |
println(String log) |
private Object |
writeReplace() |
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, removeHandler, setFilter, setLevel, setParent, setResourceBundle, setUseParentHandlers, severe, severe, throwing, warning, warning
public static final Level SEVERE
public static final Level WARNING
public static final Level INFO
public static final Level CONFIG
public static final Level FINE
public static final Level FINER
public static final Level FINEST
public static final Level ALL
public static final Level OFF
private static Map wrappers
private static PrintStream logStream
private Logger(String name, String resourceBundleName)
name
- A name for the loggerresourceBundleName
- Name of ResourceBundle to be used for localizing messages for this logger. May be null if none of the messages require localization.private Object writeReplace() throws ObjectStreamException
ObjectStreamException
public static Logger getMyLogger(String name)
name
- The name of the logger.public static void initialize(Properties pp)
public static void println(String log)