java.util.logging
public
abstract
class
java.util.logging.Handler
A 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
.
Known Direct Subclasses
MemoryHandler |
A Handler put the description of log events into a cycled memory
buffer. |
StreamHandler |
A StreamHandler object writes log messages to an output
stream, that is, objects of the class java.io.OutputStream . |
Known Indirect Subclasses
ConsoleHandler |
A handler that writes log messages to the standard output stream
System.err . |
FileHandler |
A Handler writes description of logging event into a specified
file or a rotating set of files. |
SocketHandler |
A handler that writes log messages to a socket connection. |
Summary
Protected Constructors
Public Methods
Protected Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Protected Constructors
protected
Handler()
Constructs a Handler
object with a default error manager,
the default encoding, and the default logging level
Level.ALL
. It has no filter and no formatter.
Public Methods
public
abstract
void
close()
Closes this handler. A flush operation will usually be performed and all
the associated resources will be freed. Client applications should not
use a handler after closing it.
Throws
SecurityException
| If a security manager determines that the caller does not
have the required permission.
|
public
abstract
void
flush()
Flushes any buffered output.
public
String
getEncoding()
Gets the character encoding used by this handler.
Returns
- the character encoding used by this handler
public
ErrorManager
getErrorManager()
Gets the error manager used by this handler to report errors during
logging.
Returns
- the error manager used by this handler
Throws
SecurityException
| If a security manager determines that the caller does not
have the required permission.
|
public
Filter
getFilter()
Gets the filter used by this handler.
Returns
- the filter used by this handler
public
Formatter
getFormatter()
Gets the formatter used by this handler to format the logging messages.
Returns
- the formatter used by this handler
public
Level
getLevel()
Gets the logging level of this handler.
Returns
- the logging level of this handler
public
boolean
isLoggable(LogRecord record)
Determines whether the supplied log record need to be logged. The logging
levels will be checked as well as the filter.
Parameters
record
| the log record to be checked |
Returns
true
if the supplied log record need to be logged,
otherwise false
public
abstract
void
publish(LogRecord record)
Accepts an actual logging request.
Parameters
record
| the log record to be logged
|
public
void
setEncoding(String encoding)
Sets the character encoding used by this handler. A
null
value indicates the using of the default encoding.
Parameters
encoding
| the character encoding to set |
public
void
setErrorManager(ErrorManager em)
Sets the error manager for this handler.
Parameters
em
| the error manager to set |
Throws
SecurityException
| If a security manager determines that the caller does not
have the required permission.
|
public
void
setFilter(Filter newFilter)
Sets the filter to be used by this handler.
Parameters
newFilter
| the filter to set |
Throws
SecurityException
| If a security manager determines that the caller does not
have the required permission.
|
public
void
setFormatter(Formatter newFormatter)
Sets the formatter to be used by this handler.
Parameters
newFormatter
| the formatter to set |
Throws
SecurityException
| If a security manager determines that the caller does not
have the required permission.
|
public
void
setLevel(Level newLevel)
Sets the logging level of this handler.
Parameters
newLevel
| the logging level to set |
Throws
SecurityException
| If a security manager determines that the caller does not
have the required permission.
|
Protected Methods
protected
void
reportError(String msg, Exception ex, int code)
Report an error to the error manager associated with this handler.
Parameters
msg
| the error message |
ex
| the associated exception |
code
| the error code
|