public class StreamHandler extends Handler
StreamHandler object writes log messages to an output stream, that
is, objects of the class OutputStream.
A StreamHandler object reads the following properties from the log
manager to initialize itself. A default value will be used if a property is
not found or has an invalid value.
Filter is used by
default.
java.util.logging.SimpleFormatter.
Level.INFO.
This class is not thread-safe.
| Constructor and Description |
|---|
StreamHandler()
Constructs a
StreamHandler object. |
StreamHandler(OutputStream os,
Formatter formatter)
Constructs a
StreamHandler object with the supplied output stream
and formatter. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this handler.
|
void |
flush()
Flushes any buffered output.
|
boolean |
isLoggable(LogRecord record)
Determines whether the supplied log record needs to be logged.
|
void |
publish(LogRecord record)
Accepts a logging request.
|
void |
setEncoding(String charsetName)
Sets the character encoding used by this handler.
|
protected void |
setOutputStream(OutputStream os)
Sets the output stream this handler writes to.
|
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, reportError, setErrorManager, setFilter, setFormatter, setLevelpublic StreamHandler()
StreamHandler object. The new stream handler
does not have an associated output stream.public StreamHandler(OutputStream os, Formatter formatter)
StreamHandler object with the supplied output stream
and formatter.os - the output stream this handler writes to.formatter - the formatter this handler uses to format the output.NullPointerException - if os or formatter is null.protected void setOutputStream(OutputStream os)
os.os - the new output stream.NullPointerException - if os is null.public void setEncoding(String charsetName) throws UnsupportedEncodingException
null value
indicates that the default encoding should be used.setEncoding in class HandlerUnsupportedEncodingException - if charsetName is not supported.public void close()
public void publish(LogRecord record)
null.
public boolean isLoggable(LogRecord record)
null, this method returns
false.
Notice : Case of no output stream will return false.
isLoggable in class Handlerrecord - the log record to be checked.true if record needs to be logged, false
otherwise.