public class WriterHandler extends HandlerSkeleton
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
bufferedIO
Do we do bufferedIO?
|
protected int |
bufferSize
Determines the size of IO buffer be.
|
protected boolean |
immediateFlush
Immediate flush means that the underlying writer or output stream will be
flushed at the end of each append operation.
|
name| Constructor and Description |
|---|
WriterHandler() |
WriterHandler(OutputStream output,
Formatter formatter) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
checkEntryConditions(LogRecord record) |
void |
close() |
void |
flush() |
int |
getBufferSize() |
boolean |
getImmediateFlush() |
boolean |
isBufferedIO() |
void |
publish(LogRecord record) |
void |
setBufferedIO(boolean bufferedIO)
The BufferedIO option takes a boolean value.
|
void |
setBufferSize(int bufferSize)
Set the size of the IO buffer.
|
void |
setEncoding(String encoding) |
void |
setImmediateFlush(boolean value)
If the ImmediateFlush option is set to
true, the
appender will flush at the end of each write. |
protected void |
setOutputStream(OutputStream out)
Change the output stream.
|
protected void |
subPublish(LogRecord record)
Actual writing occurs here.
|
activateOptions, debug, getName, setNamegetEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setErrorManager, setFilter, setFormatter, setLevelprotected boolean immediateFlush
immediateFlush is set to false, then there is a
good chance that the last few logs events are not actually written to
persistent media if and when the application crashes.
The immediateFlush variable is set to true by
default.protected boolean bufferedIO
protected int bufferSize
public WriterHandler()
public WriterHandler(OutputStream output, Formatter formatter)
public void setImmediateFlush(boolean value)
true, the
appender will flush at the end of each write. This is the default
behavior. If the option is set to false, then the underlying
stream can defer writing to physical medium to a later time.
Avoiding the flush operation at the end of each append results in a
performance gain of 10 to 20 percent. However, there is safety tradeoff
involved in skipping flushing. Indeed, when flushing is skipped, then it
is likely that the last few log events will not be recorded on disk when
the application exits. This is a high price to pay even for a 20%
performance gain.value - The flag that controls immediate flushpublic boolean getImmediateFlush()
public boolean isBufferedIO()
public void setBufferedIO(boolean bufferedIO)
false by default. If true, then File will be
opened and the resulting Writer wrapped around a BufferedWriter.
BufferedIO will significatnly increase performance on heavily loaded systems.bufferedIO - The flag that controls IO buffering.public int getBufferSize()
public void setBufferSize(int bufferSize)
bufferSize - The buffer size to usepublic void setEncoding(String encoding) throws SecurityException, UnsupportedEncodingException
setEncoding in class HandlerSecurityExceptionUnsupportedEncodingExceptionprotected boolean checkEntryConditions(LogRecord record)
protected void subPublish(LogRecord record)
record - The log record to write.protected void setOutputStream(OutputStream out)
out - New output stream. May not be null.SecurityException - if a security manager exists and if the caller
does not have LoggingPermission("control").