Datasheet
Method Description
abstract void close() Should perform a flush() and then free any resources
used by the handler. After
close() is called, the Handler
should no longer be used.
abstract void flush() Flushes any buffered output to ensure it is saved to the
associated resource.
abstract void Takes a log message forwarded by a logger and then
publish(LogRecord record) writes it to the associated resource. The message should be
formatted (using the
Formatter) and localized.
Set and Retrieve Information about the Handler
The methods listed in the following table allow you to retrieve information about the handler, such as its
encoding, associated error manager, filter, formatter, and level, and also set this configuration information.
Method Description
String getEncoding() Returns the name of the character encoding. If the name is
null, the default encoding should be used.
ErrorManager getErrorManager() Returns the ErrorManager associated with this Handler.
Filter getFilter() Returns the Filter associated with this Handler, which
might be null.
Formatter getFormatter() Returns the Formatter associated with this Handler,
which might be null.
Level getLevel() Returns the level of this handler. Log messages lower than
this level are discarded.
boolean isLoggable(LogRecord Returns true if the LogRecord passed in will be logged by
record) this handler. The checks include comparing the record’s
level to the handler’s, testing against the filter (if one is
defined), and any other checks defined in the handler.
void setEncoding(String Sets the encoding to a specified character encoding. If null
encoding) is passed in, the default platform encoding is used.
void setErrorManager Sets an ErrorManager for the handler. If any errors occur
(ErrorManager em) while processing, the Error Manager’s error method is
invoked.
void setFilter (Filter Sets a custom filter that decides whether to discard or keep
newFilter) a log message when the publish method is invoked.
void setFormatter (Formatter Sets a Formatter that performs custom formatting on log
newFormatter) messages passed to the handler before the log message is
written to the destination.
void setLevel(Level newLevel) Sets the level threshold for the handler. Log messages
below this level are automatically discarded.
47
Chapter 1: Key Java Language Features and Libraries
05_777106 ch01.qxp 11/28/06 10:43 PM Page 47