ConsoleHandler (Java SE 9 & JDK 9 ) (original) (raw)
- java.util.logging.Handler
- java.util.logging.StreamHandler
- java.util.logging.ConsoleHandler
- java.util.logging.StreamHandler
public class ConsoleHandler
extends StreamHandler
This Handler
publishes log records to System.err
. By default the SimpleFormatter
is used to generate brief summaries.
Configuration: By default each ConsoleHandler
is initialized using the followingLogManager
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.
.level specifies the default level for the
Handler
(defaults toLevel.INFO
)..filter specifies the name of a
Filter
class to use (defaults to noFilter
)..formatter specifies the name of a
Formatter
class to use (defaults tojava.util.logging.SimpleFormatter
)..encoding the name of the character set encoding to use (defaults to the default platform encoding).
For example, the properties forConsoleHandler
would be:java.util.logging.ConsoleHandler.level=INFO
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
For a custom handler, e.g. com.foo.MyHandler, the properties would be:com.foo.MyHandler.level=INFO
com.foo.MyHandler.formatter=java.util.logging.SimpleFormatter
Since:
1.4Constructor Summary
Constructors
Constructor Description ConsoleHandler() Create a ConsoleHandler for System.err. Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type Method Description void close() Override StreamHandler.close to do a flush but not to close the output stream. void publish(LogRecord record) Publish a LogRecord. * ### Methods inherited from class java.util.logging.[Handler](../../../java/util/logging/Handler.html "class in java.util.logging") `[getEncoding](../../../java/util/logging/Handler.html#getEncoding--), [getErrorManager](../../../java/util/logging/Handler.html#getErrorManager--), [getFilter](../../../java/util/logging/Handler.html#getFilter--), [getFormatter](../../../java/util/logging/Handler.html#getFormatter--), [getLevel](../../../java/util/logging/Handler.html#getLevel--), [reportError](../../../java/util/logging/Handler.html#reportError-java.lang.String-java.lang.Exception-int-), [setErrorManager](../../../java/util/logging/Handler.html#setErrorManager-java.util.logging.ErrorManager-), [setFilter](../../../java/util/logging/Handler.html#setFilter-java.util.logging.Filter-), [setFormatter](../../../java/util/logging/Handler.html#setFormatter-java.util.logging.Formatter-), [setLevel](../../../java/util/logging/Handler.html#setLevel-java.util.logging.Level-)` * ### Methods inherited from class java.lang.[Object](../../../java/lang/Object.html "class in java.lang") `[clone](../../../java/lang/Object.html#clone--), [equals](../../../java/lang/Object.html#equals-java.lang.Object-), [finalize](../../../java/lang/Object.html#finalize--), [getClass](../../../java/lang/Object.html#getClass--), [hashCode](../../../java/lang/Object.html#hashCode--), [notify](../../../java/lang/Object.html#notify--), [notifyAll](../../../java/lang/Object.html#notifyAll--), [toString](../../../java/lang/Object.html#toString--), [wait](../../../java/lang/Object.html#wait--), [wait](../../../java/lang/Object.html#wait-long-), [wait](../../../java/lang/Object.html#wait-long-int-)` * ### Methods inherited from class java.util.logging.[StreamHandler](../../../java/util/logging/StreamHandler.html "class in java.util.logging") `[flush](../../../java/util/logging/StreamHandler.html#flush--), [isLoggable](../../../java/util/logging/StreamHandler.html#isLoggable-java.util.logging.LogRecord-), [setEncoding](../../../java/util/logging/StreamHandler.html#setEncoding-java.lang.String-), [setOutputStream](../../../java/util/logging/StreamHandler.html#setOutputStream-java.io.OutputStream-)`
Constructor Detail
* #### ConsoleHandler public ConsoleHandler() Create a `ConsoleHandler` for `System.err`. The `ConsoleHandler` is configured based on`LogManager` properties (or their default values).
Method Detail
* #### publish public void publish([LogRecord](../../../java/util/logging/LogRecord.html "class in java.util.logging") record) Publish a `LogRecord`. The logging request was made initially to a `Logger` object, which initialized the `LogRecord` and forwarded it here. Overrides: `[publish](../../../java/util/logging/StreamHandler.html#publish-java.util.logging.LogRecord-)` in class `[StreamHandler](../../../java/util/logging/StreamHandler.html "class in java.util.logging")` Parameters: `record` \- description of the log event. A null record is silently ignored and is not published * #### close public void close() Override `StreamHandler.close` to do a flush but not to close the output stream. That is, we do **not** close `System.err`. Overrides: `[close](../../../java/util/logging/StreamHandler.html#close--)` in class `[StreamHandler](../../../java/util/logging/StreamHandler.html "class in java.util.logging")`
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2017, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.