Skip to content

Most visited

Recently visited

navigation
Added in API level 1

Handler

public abstract class Handler
extends Object

java.lang.Object
   ↳ java.util.logging.Handler
Known Direct Subclasses
Known Indirect Subclasses


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.

Summary

Protected constructors

Handler()

Constructs a Handler object with a default error manager instance ErrorManager, the default encoding, and the default logging level Level.ALL.

Public methods

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.

void setEncoding(String charsetName)

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 methods

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.

Inherited methods

From class java.lang.Object

Protected constructors

Handler

Added in API level 1
Handler ()

Constructs a 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 methods

close

Added in API level 1
void close ()

Closes this handler. A flush operation will be performed and all the associated resources will be freed. Client applications should not use this handler after closing it.

flush

Added in API level 1
void flush ()

Flushes any buffered output.

getEncoding

Added in API level 1
String getEncoding ()

Gets the character encoding used by this handler, null for default encoding.

Returns
String the character encoding used by this handler.

getErrorManager

Added in API level 1
ErrorManager getErrorManager ()

Gets the error manager used by this handler to report errors during logging.

Returns
ErrorManager the error manager used by this handler.

getFilter

Added in API level 1
Filter getFilter ()

Gets the filter used by this handler.

Returns
Filter the filter used by this handler (possibly null).

getFormatter

Added in API level 1
Formatter getFormatter ()

Gets the formatter used by this handler to format the logging messages.

Returns
Formatter the formatter used by this handler (possibly null).

getLevel

Added in API level 1
Level getLevel ()

Gets the logging level of this handler, records with levels lower than this value will be dropped.

Returns
Level the logging level of this handler.

isLoggable

Added in API level 1
boolean isLoggable (LogRecord record)

Determines whether the supplied log record needs to be logged. The logging levels will be checked as well as the filter.

Parameters
record LogRecord: the log record to be checked.
Returns
boolean true if the supplied log record needs to be logged, otherwise false.

publish

Added in API level 1
void publish (LogRecord record)

Accepts a logging request and sends it to the the target.

Parameters
record LogRecord: the log record to be logged; null records are ignored.

setEncoding

Added in API level 1
void setEncoding (String charsetName)

Sets the character encoding used by this handler, null indicates a default encoding.

Parameters
charsetName String
Throws
UnsupportedEncodingException if charsetName is not supported.

setErrorManager

Added in API level 1
void setErrorManager (ErrorManager newErrorManager)

Sets the error manager for this handler.

Parameters
newErrorManager ErrorManager: the error manager to set.
Throws
NullPointerException if em is null.

setFilter

Added in API level 1
void setFilter (Filter newFilter)

Sets the filter to be used by this handler.

Parameters
newFilter Filter: the filter to set, may be null.

setFormatter

Added in API level 1
void setFormatter (Formatter newFormatter)

Sets the formatter to be used by this handler.

Parameters
newFormatter Formatter: the formatter to set.
Throws
NullPointerException if newFormatter is null.

setLevel

Added in API level 1
void setLevel (Level newLevel)

Sets the logging level of the messages logged by this handler, levels lower than this value will be dropped.

Parameters
newLevel Level: the logging level to set.
Throws
NullPointerException if newLevel is null.

Protected methods

reportError

Added in API level 1
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. No security checks are done, therefore this is compatible with environments where the caller is non-privileged.

Parameters
msg String: the error message, may be null.
ex Exception: the associated exception, may be null.
code int: an ErrorManager error code.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.