ConsoleHandler
Stay organized with collections
Save and categorize content based on your preferences.
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 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-name>.level
specifies the default level for the Handler
(defaults to Level.INFO).
- <handler-name>.filter
specifies the name of a Filter class to use
(defaults to no Filter).
- <handler-name>.formatter
specifies the name of a Formatter class to use
(defaults to java.util.logging.SimpleFormatter).
- <handler-name>.encoding
the name of the character set encoding to use (defaults to
the default platform encoding).
For example, the properties for ConsoleHandler
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
Public Constructor Summary
Public Method Summary
void
|
close()
Override StreamHandler.close to do a flush but not
to close the output stream.
|
void
|
|
Inherited Method Summary
From class
java.util.logging.StreamHandler
synchronized
void
|
close()
Close the current output stream.
|
synchronized
void
|
flush()
Flush any buffered messages.
|
boolean
|
|
synchronized
void
|
|
synchronized
void
|
setEncoding( String encoding)
Set (or change) the character encoding used by this Handler.
|
synchronized
void
|
|
From class
java.util.logging.Handler
abstract
void
|
close()
Close the Handler and free all associated resources.
|
abstract
void
|
flush()
Flush any buffered output.
|
String
|
getEncoding()
Return the character encoding for this Handler.
|
ErrorManager
|
|
Filter
|
getFilter()
Get the current Filter for this Handler.
|
Formatter
|
|
Level
|
getLevel()
Get the log level specifying which messages will be
logged by this Handler.
|
boolean
|
|
abstract
void
|
|
void
|
|
synchronized
void
|
|
synchronized
void
|
|
synchronized
void
|
setFilter( Filter newFilter)
Set a Filter to control output on this Handler.
|
synchronized
void
|
|
synchronized
void
|
setLevel( Level newLevel)
Set the log level specifying which message levels will be
logged by this Handler.
|
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals( Object obj)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
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()
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
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait(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(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()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
Public Constructors
public
ConsoleHandler
()
Create a ConsoleHandler for System.err.
The ConsoleHandler is configured based on
LogManager properties (or their default values).
Public Methods
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.
public
void
publish
(LogRecord record)
Publish a LogRecord.
The logging request was made initially to a Logger object,
which initialized the LogRecord and forwarded it here.
Parameters
record |
description of the log event. A null record is
silently ignored and is not published
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2024-07-10 UTC."}