Datasheet
Method Description
static Level Returns a Level object representing the name of the level that is
parse(String name) passed in. The string name can be one of the logging levels,
such as
SEVERE or CONFIG. An arbitrary number, between
Integer.MIN_VALUE and Integer.MAX_VALUE can also be
passed in (as a string). If the number represents one of the exist-
ing level values, that level is returned. Otherwise, a new
Level
is returned corresponding to the passed in value. Any invalid
name or number causes an
IllegalArgumentException to get
thrown. If the name is null, a
NullPointerException is thrown.
boolean equals(Object ox) Returns true if the object passed in has the same level as the cur-
rent class.
String getLocalizedName() Returns the localized version of the current level’s name, or the
non-localized version if no localization is available.
String getName() Returns the non-localized version of the current level’s name.
String Returns the name of the level’s localization resource bundle, or
getResourceBundleName() null if no localization resource bundle is defined.
int hashCode() Returns a hash code based on the level value.
int intValue() Returns the integer value for the current level.
String toString() Returns the non-localized name of the current level.
The Handler Class
The Handler class is used to receive log messages and then publish them to an external destination. This
might be memory, a file, a database, a TCP/IP stream, or any number of places that can store log mes-
sages. Just like loggers, a handler has an associated level. Log messages that are less than the level on the
handler are discarded. Each specific instance of a
Handler has its own properties and is usually config-
ured in the
logging.properties file. The next section discusses the various handlers that are found in
the
java.util.logging package. Creating a custom handler is straightforward, because implementa-
tions of only
close(), flush(), and publish(LogRecord record) are needed.
Handler Methods
The Handler class defines three abstract methods that need specific behavior in inheriting classes. The
other methods available on the
Handler class are for dealing with message encoding, filters, formatters,
and error handlers.
Key Abstract Methods
When developing a custom handler, there are three abstract methods that must be overridden. These are
listed in the following table.
46
Part I: Thinking Like a Java Developer
05_777106 ch01.qxp 11/28/06 10:43 PM Page 46