# Handler

public abstract class **Handler** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  

|---|---|---|
| Known Direct Subclasses [MemoryHandler](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/MemoryHandler.html), [StreamHandler](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/StreamHandler.html) |---|---| | [MemoryHandler](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/MemoryHandler.html) | Handler that buffers requests in a circular buffer in memory. | | [StreamHandler](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/StreamHandler.html) | Stream based logging Handler. | |||

|---|---|---|
| Known Indirect Subclasses [ConsoleHandler](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/ConsoleHandler.html), [FileHandler](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/FileHandler.html) |---|---| | [ConsoleHandler](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/ConsoleHandler.html) | This Handler publishes log records to System.err. | | [FileHandler](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/FileHandler.html) | Simple file logging Handler. | |||

A Handler object takes log messages from a Logger and
exports them. It might for example, write them to a console
or write them to a file, or send them to a network logging service,
or forward them to an OS log, or whatever.


A Handler can be disabled by doing a setLevel(Level.OFF)
and can be re-enabled by doing a setLevel with an appropriate level.


Handler classes typically use LogManager properties to set
default values for the Handler's Filter, Formatter,
and Level. See the specific documentation for each concrete
Handler class.

### Protected Constructor Summary

|---|---|
|   | [Handler](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Handler.html#Handler())() Default constructor. |

### Public Method Summary

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Handler.html#close())() Close the Handler and free all associated resources. |
| abstract void | [flush](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Handler.html#flush())() Flush any buffered output. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getEncoding](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Handler.html#getEncoding())() Return the character encoding for this Handler. |
| [ErrorManager](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/ErrorManager.html) | [getErrorManager](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Handler.html#getErrorManager())() Retrieves the ErrorManager for this Handler. |
| [Filter](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Filter.html) | [getFilter](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Handler.html#getFilter())() Get the current Filter for this Handler. |
| [Formatter](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Formatter.html) | [getFormatter](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Handler.html#getFormatter())() Return the Formatter for this Handler. |
| [Level](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Level.html) | [getLevel](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Handler.html#getLevel())() Get the log level specifying which messages will be logged by this Handler. |
| boolean | [isLoggable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Handler.html#isLoggable(java.util.logging.LogRecord))([LogRecord](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogRecord.html) record) Check if this Handler would actually log a given LogRecord. |
| abstract void | [publish](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Handler.html#publish(java.util.logging.LogRecord))([LogRecord](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogRecord.html) record) Publish a LogRecord. |
| synchronized void | [setEncoding](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Handler.html#setEncoding(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) encoding) Set the character encoding used by this Handler. |
| synchronized void | [setErrorManager](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Handler.html#setErrorManager(java.util.logging.ErrorManager))([ErrorManager](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/ErrorManager.html) em) Define an ErrorManager for this Handler. |
| synchronized void | [setFilter](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Handler.html#setFilter(java.util.logging.Filter))([Filter](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Filter.html) newFilter) Set a Filter to control output on this Handler. |
| synchronized void | [setFormatter](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Handler.html#setFormatter(java.util.logging.Formatter))([Formatter](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Formatter.html) newFormatter) Set a Formatter. |
| synchronized void | [setLevel](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Handler.html#setLevel(java.util.logging.Level))([Level](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Level.html) newLevel) Set the log level specifying which message levels will be logged by this Handler. |

### Protected Method Summary

|---|---|
| void | [reportError](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Handler.html#reportError(java.lang.String,%20java.lang.Exception,%20int))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) msg, [Exception](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Exception.html) ex, int code) Protected convenience method to report an error to this Handler's ErrorManager. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Protected Constructors

#### protected
**Handler**
()

Default constructor. The resulting Handler has a log
level of Level.ALL, no Formatter, and no
Filter. A default ErrorManager instance is installed
as the ErrorManager.

## Public Methods

#### public abstract void
**close**
()

Close the Handler and free all associated resources.


The close method will perform a flush and then close the
Handler. After close has been called this Handler
should no longer be used. Method calls may either be silently
ignored or may throw runtime exceptions.

##### Throws

| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and if the caller does not have LoggingPermission("control"). |
|---|---|

#### public abstract void
**flush**
()

Flush any buffered output.

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**getEncoding**
()

Return the character encoding for this Handler.

##### Returns

- The encoding name. May be null, which indicates the default encoding should be used.

#### public [ErrorManager](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/ErrorManager.html)
**getErrorManager**
()

Retrieves the ErrorManager for this Handler.

##### Returns

- the ErrorManager for this Handler

##### Throws

| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and if the caller does not have LoggingPermission("control"). |
|---|---|

#### public [Filter](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Filter.html)
**getFilter**
()

Get the current Filter for this Handler.

##### Returns

- a Filter object (may be null)

#### public [Formatter](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Formatter.html)
**getFormatter**
()

Return the Formatter for this Handler.

##### Returns

- the Formatter (may be null).

#### public [Level](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Level.html)
**getLevel**
()

Get the log level specifying which messages will be
logged by this Handler. Message levels lower
than this level will be discarded.

##### Returns

- the level of messages being logged.

#### public boolean
**isLoggable**
([LogRecord](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogRecord.html) record)

Check if this Handler would actually log a given LogRecord.


This method checks if the LogRecord has an appropriate
Level and whether it satisfies any Filter. It also
may make other Handler specific checks that might prevent a
handler from logging the LogRecord. It will return false if
the LogRecord is null.

<br />

##### Parameters

| record | a LogRecord |
|---|---|

##### Returns

- true if the LogRecord would be logged.

#### public abstract void
**publish**
([LogRecord](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/LogRecord.html) record)

Publish a LogRecord.


The logging request was made initially to a Logger object,
which initialized the LogRecord and forwarded it here.


The Handler is responsible for formatting the message, when and
if necessary. The formatting should include localization.

##### Parameters

| record | description of the log event. A null record is silently ignored and is not published |
|---|---|

#### public synchronized void
**setEncoding**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) encoding)

Set the character encoding used by this Handler.


The encoding should be set before any LogRecords are written
to the Handler.

##### Parameters

| encoding | The name of a supported character encoding. May be null, to indicate the default platform encoding. |
|---|---|

##### Throws

| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and if the caller does not have LoggingPermission("control"). |
| [UnsupportedEncodingException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/UnsupportedEncodingException.html) | if the named encoding is not supported. |
|---|---|

#### public synchronized void
**setErrorManager**
([ErrorManager](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/ErrorManager.html) em)

Define an ErrorManager for this Handler.


The ErrorManager's "error" method will be invoked if any
errors occur while using this Handler.

##### Parameters

| em | the new ErrorManager |
|---|---|

##### Throws

| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and if the caller does not have LoggingPermission("control"). |
|---|---|

#### public synchronized void
**setFilter**
([Filter](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Filter.html) newFilter)

Set a Filter to control output on this Handler.


For each call of publish the Handler will call
this Filter (if it is non-null) to check if the
LogRecord should be published or discarded.

##### Parameters

| newFilter | a Filter object (may be null) |
|---|---|

##### Throws

| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and if the caller does not have LoggingPermission("control"). |
|---|---|

#### public synchronized void
**setFormatter**
([Formatter](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Formatter.html) newFormatter)

Set a Formatter. This Formatter will be used
to format LogRecords for this Handler.


Some Handlers may not use Formatters, in
which case the Formatter will be remembered, but not used.

<br />

##### Parameters

| newFormatter | the Formatter to use (may not be null) |
|---|---|

##### Throws

| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and if the caller does not have LoggingPermission("control"). |
|---|---|

#### public synchronized void
**setLevel**
([Level](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/logging/Level.html) newLevel)

Set the log level specifying which message levels will be
logged by this Handler. Message levels lower than this
value will be discarded.


The intention is to allow developers to turn on voluminous
logging, but to limit the messages that are sent to certain
Handlers.

##### Parameters

| newLevel | the new value for the log level |
|---|---|

##### Throws

| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and if the caller does not have LoggingPermission("control"). |
|---|---|

## Protected Methods

#### protected void
**reportError**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) msg, [Exception](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Exception.html) ex, int code)

Protected convenience method to report an error to this Handler's
ErrorManager. Note that this method retrieves and uses the ErrorManager
without doing a security check. It can therefore be used in
environments where the caller may be non-privileged.

##### Parameters

| msg | a descriptive string (may be null) |
| ex | an exception (may be null) |
| code | an error code defined in ErrorManager |
|---|---|