|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.UnsynchronizedAppenderBase<E>
ch.qos.logback.core.WriterAppender<E>
public class WriterAppender<E>
WriterAppender appends events to a hava.io.Writer. This class provides basic services that other appenders build upon. For more information about this appender, please refer to the online manual at http://logback.qos.ch/manual/appenders.html#WriterAppender
Field Summary |
---|
Fields inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase |
---|
layout, name, started |
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase |
---|
context |
Constructor Summary | |
---|---|
WriterAppender()
The default constructor does nothing. |
Method Summary | |
---|---|
protected void |
append(E eventObject)
|
protected void |
closeWriter()
Close the underlying Writer . |
protected OutputStreamWriter |
createWriter(OutputStream os)
Returns an OutputStreamWriter when passed an OutputStream. |
String |
getEncoding()
|
boolean |
getImmediateFlush()
Returns value of the ImmediateFlush option. |
void |
setEncoding(String value)
|
void |
setImmediateFlush(boolean value)
If the ImmediateFlush option is set to true , the
appender will flush at the end of each write. |
void |
setWriter(Writer writer)
Sets the Writer where the log output will go. |
void |
start()
Checks that requires parameters are set and if everything is in order, activates this appender. |
void |
stop()
Stop this appender instance. |
protected void |
subAppend(E event)
Actual writing occurs here. |
protected void |
writerWrite(String s,
boolean flush)
|
Methods inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase |
---|
addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getFirstFilter, getLayout, getName, isStarted, setLayout, setName, toString |
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase |
---|
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ch.qos.logback.core.spi.ContextAware |
---|
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext |
Constructor Detail |
---|
public WriterAppender()
Method Detail |
---|
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.
public boolean getImmediateFlush()
public void start()
start
in interface LifeCycle
start
in class UnsynchronizedAppenderBase<E>
protected void append(E eventObject)
append
in class UnsynchronizedAppenderBase<E>
public void stop()
Stopped appenders cannot be reused.
stop
in interface LifeCycle
stop
in class UnsynchronizedAppenderBase<E>
protected void closeWriter()
Writer
.
protected OutputStreamWriter createWriter(OutputStream os)
encoding
property. If
the encoding value is specified incorrectly the writer will be opened using
the default system encoding (an error message will be printed to the
loglog.
public String getEncoding()
public void setEncoding(String value)
public void setWriter(Writer writer)
Sets the Writer where the log output will go. The specified Writer must be
opened by the user and be writable. The java.io.Writer
will
be closed when the appender instance is closed.
writer
- An already opened Writer.protected void writerWrite(String s, boolean flush) throws IOException
IOException
protected void subAppend(E event)
Most subclasses of WriterAppender
will need to override this
method.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |