|
Logback API Version 0.9.8 |
|||||||||
| 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.AppenderBase<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 | |
|---|---|
protected String |
encoding
The encoding to use when opening an InputStream. |
protected boolean |
immediateFlush
Immediate flush means that the underlying writer or output stream will be flushed at the end of each append operation. |
protected Layout<E> |
layout
The layout variable does not need to be set if the appender implementation has its own layout. |
protected Writer |
writer
This is the Writer where we will write to. |
| Fields inherited from class ch.qos.logback.core.AppenderBase |
|---|
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. |
Layout<E> |
getLayout()
Returns the layout of this appender. |
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 |
setLayout(Layout<E> layout)
Set the layout for this appender. |
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. |
| Methods inherited from class ch.qos.logback.core.AppenderBase |
|---|
addFilter, clearAllFilters, doAppend, getFilterChainDecision, getFirstFilter, getName, isStarted, setName, toString |
| Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase |
|---|
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, 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 |
| Field Detail |
|---|
protected 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 String encoding
The
encoding variable is set to null by default
which results in the use of the system's default encoding.
protected Writer writer
Writer where we will write to.
protected Layout<E> layout
| 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 LifeCyclestart in class AppenderBase<E>protected void append(E eventObject)
append in class AppenderBase<E>public void stop()
Stopped appenders cannot be reused.
stop in interface LifeCyclestop in class AppenderBase<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 setLayout(Layout<E> layout)
setLayout in interface Appender<E>setLayout in class AppenderBase<E>public Layout<E> getLayout()
getLayout in interface Appender<E>getLayout in class AppenderBase<E>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 subAppend(E event)
Most subclasses of WriterAppender will need to override this
method.
|
Logback API Version 0.9.8 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||