public abstract class Handler extends Object
Handler
object accepts a logging request and exports the desired
messages to a target, for example, a file, the console, etc. It can be
disabled by setting its logging level to Level.OFF
.Modifier | Constructor and Description |
---|---|
protected |
Handler()
Constructs a
Handler object with a default error manager instance
ErrorManager , the default encoding, and the default logging
level Level.ALL . |
Modifier and Type | Method and Description |
---|---|
abstract void |
close()
Closes this handler.
|
abstract void |
flush()
Flushes any buffered output.
|
String |
getEncoding()
Gets the character encoding used by this handler,
null for
default encoding. |
ErrorManager |
getErrorManager()
Gets the error manager used by this handler to report errors during
logging.
|
Filter |
getFilter()
Gets the filter used by this handler.
|
Formatter |
getFormatter()
Gets the formatter used by this handler to format the logging messages.
|
Level |
getLevel()
Gets the logging level of this handler, records with levels lower than
this value will be dropped.
|
boolean |
isLoggable(LogRecord record)
Determines whether the supplied log record needs to be logged.
|
abstract void |
publish(LogRecord record)
Accepts a logging request and sends it to the the target.
|
protected void |
reportError(String msg,
Exception ex,
int code)
Reports an error to the error manager associated with this handler,
ErrorManager is used for that purpose. |
void |
setEncoding(String encoding)
Sets the character encoding used by this handler,
null indicates
a default encoding. |
void |
setErrorManager(ErrorManager newErrorManager)
Sets the error manager for this handler.
|
void |
setFilter(Filter newFilter)
Sets the filter to be used by this handler.
|
void |
setFormatter(Formatter newFormatter)
Sets the formatter to be used by this handler.
|
void |
setLevel(Level newLevel)
Sets the logging level of the messages logged by this handler, levels
lower than this value will be dropped.
|
protected Handler()
Handler
object with a default error manager instance
ErrorManager
, the default encoding, and the default logging
level Level.ALL
. It has no filter and no formatter.public abstract void close()
public abstract void flush()
public abstract void publish(LogRecord record)
record
- the log record to be logged; null
records are ignored.public String getEncoding()
null
for
default encoding.public ErrorManager getErrorManager()
public Filter getFilter()
null
).public Formatter getFormatter()
null
).public Level getLevel()
public boolean isLoggable(LogRecord record)
record
- the log record to be checked.true
if the supplied log record needs to be logged,
otherwise false
.protected void reportError(String msg, Exception ex, int code)
ErrorManager
is used for that purpose. No security checks are
done, therefore this is compatible with environments where the caller
is non-privileged.msg
- the error message, may be null
.ex
- the associated exception, may be null
.code
- an ErrorManager
error code.public void setEncoding(String encoding) throws UnsupportedEncodingException
null
indicates
a default encoding.encoding
- the character encoding to set.UnsupportedEncodingException
- if the specified encoding is not supported by the runtime.public void setErrorManager(ErrorManager newErrorManager)
newErrorManager
- the error manager to set.NullPointerException
- if em
is null
.public void setFilter(Filter newFilter)
newFilter
- the filter to set, may be null
.public void setFormatter(Formatter newFormatter)
newFormatter
- the formatter to set.NullPointerException
- if newFormatter
is null
.public void setLevel(Level newLevel)
newLevel
- the logging level to set.NullPointerException
- if newLevel
is null
.