Handler.
This is primarily intended as a base class or support class to
be used in implementing other logging Handlers.
LogRecords are published to a given java.io.OutputStream.
Configuration:
By default each StreamHandler is initialized using the following
LogManager configuration properties where <handler-name>
refers to the fully-qualified class name of the handler.
If properties are not defined
(or have invalid values) then the specified default values are used.
Handler
(defaults to Level.INFO). Filter class to use
(defaults to no Filter). Formatter class to use
(defaults to java.util.logging.SimpleFormatter).
For example, the properties for StreamHandler would be:
For a custom handler, e.g. com.foo.MyHandler, the properties would be:
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private OutputStream | |
| private volatile Writer |
| Access | Constructor and Description |
|---|---|
| public | |
| public | StreamHandler(OutputStream
the target output stream out, Formatter Formatter to be used to format output formatter)Create a |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void | |
| public synchronized void | |
| private void | |
| public boolean | Returns: true if theLogRecord would be logged.a record)LogRecord (may be null).Overrides java. Check if this |
| public void | publish(LogRecord
description of the log event. A null record is
silently ignored and is not published record)Implements abstract java. Format and publish a |
| public synchronized void | setEncoding(String
The name of a supported character encoding.
May be null, to indicate the default platform encoding. encoding)Overrides java. Set (or change) the character encoding used by this |
| protected synchronized void | |
| pack-priv void | synchronousPostWriteHook()
Overridden by other handlers in this package to facilitate synchronous post-write behaviour. |
| doneHeader | back to summary |
|---|---|
| private boolean doneHeader | |
| output | back to summary |
|---|---|
| private OutputStream output | |
| writer | back to summary |
|---|---|
| private volatile Writer writer | |
| StreamHandler | back to summary |
|---|---|
| public StreamHandler() Create a | |
| StreamHandler | back to summary |
|---|---|
| public StreamHandler(OutputStream out, Formatter formatter) Create a
| |
| StreamHandler | back to summary |
|---|---|
| pack-priv StreamHandler(Level defaultLevel, Formatter defaultFormatter, Formatter specifiedFormatter) | |
| close | back to summary |
|---|---|
| public synchronized void close() Implements abstract java. Close the current output stream.
The
| |
| flush | back to summary |
|---|---|
| public synchronized void flush() Implements abstract java. Flush any buffered messages.
| |
| flushAndClose | back to summary |
|---|---|
| private void flushAndClose() | |
| isLoggable | back to summary |
|---|---|
| public boolean isLoggable(LogRecord record) Overrides java. Check if this
This method checks if the | |
| publish | back to summary |
|---|---|
| public void publish(LogRecord record) Implements abstract java. Format and publish a
The
If this is the first Implementation Specification This method avoids acquiring locks during | |
| setEncoding | back to summary |
|---|---|
| public synchronized void setEncoding(String encoding) throws UnsupportedEncodingException Overrides java. Set (or change) the character encoding used by this
The encoding should be set before any
| |
| setOutputStream | back to summary |
|---|---|
| protected synchronized void setOutputStream(OutputStream out) Change the output stream.
If there is a current output stream then the
| |
| synchronousPostWriteHook | back to summary |
|---|---|
| pack-priv void synchronousPostWriteHook() Overridden by other handlers in this package to facilitate synchronous post-write behaviour. If other handlers need similar functionality, it might be feasible to make this method protected (see JDK-8349206), but please find a better name if you do ;). | |