Class AbstractOutputStreamAppender<M extends OutputStreamManager>
java.lang.Object
org.apache.logging.log4j.core.AbstractLifeCycle
org.apache.logging.log4j.core.filter.AbstractFilterable
org.apache.logging.log4j.core.appender.AbstractAppender
org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender<M>
- Type Parameters:
M- The kind ofOutputStreamManagerunder management
- All Implemented Interfaces:
Appender,Filterable,LocationAware,LifeCycle,LifeCycle2
- Direct Known Subclasses:
AbstractFileAppender,ConsoleAppender,FileAppender,MemoryMappedFileAppender,OutputStreamAppender,RandomAccessFileAppender,RollingFileAppender,RollingRandomAccessFileAppender,SocketAppender
public abstract class AbstractOutputStreamAppender<M extends OutputStreamManager>
extends AbstractAppender
Appends log events as bytes to a byte output stream. The stream encoding is defined in the layout.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSubclasses can extend this abstract Builder.Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
LifeCycle.State -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanImmediate flush means that the underlying writer or output stream will be flushed at the end of each append operation.private final MFields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGERFields inherited from interface org.apache.logging.log4j.core.Appender
ELEMENT_TYPE, EMPTY_ARRAY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractOutputStreamAppender(String name, Layout<? extends Serializable> layout, Filter filter, boolean ignoreExceptions, boolean immediateFlush, M manager) Deprecated.protectedAbstractOutputStreamAppender(String name, Layout<? extends Serializable> layout, Filter filter, boolean ignoreExceptions, boolean immediateFlush, Property[] properties, M manager) Instantiates a WriterAppender and set the output destination to a newOutputStreamWriterinitialized withosas itsOutputStream. -
Method Summary
Modifier and TypeMethodDescriptionvoidActual writing occurs here.protected voiddirectEncodeEvent(LogEvent event) booleanGets the immediate flush setting.Gets the manager.voidstart()Make the Filter available for use.booleanCleanup the Filter.protected booleanCleanup the Filter.private voidprotected voidwriteByteArrayToManager(LogEvent event) Methods inherited from class org.apache.logging.log4j.core.appender.AbstractAppender
error, error, error, getHandler, getLayout, getName, ignoreExceptions, parseInt, requiresLocation, setHandler, toSerializable, toStringMethods inherited from class org.apache.logging.log4j.core.filter.AbstractFilterable
addFilter, getFilter, getPropertyArray, hasFilter, isFiltered, removeFilterMethods inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stop
-
Field Details
-
immediateFlush
private final boolean immediateFlushImmediate flush means that the underlying writer or output stream will be flushed at the end of each append operation. Immediate flush is slower but ensures that each append request is actually written. IfimmediateFlushis set tofalse, 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. -
manager
-
-
Constructor Details
-
AbstractOutputStreamAppender
@Deprecated protected AbstractOutputStreamAppender(String name, Layout<? extends Serializable> layout, Filter filter, boolean ignoreExceptions, boolean immediateFlush, M manager) Deprecated.Instantiates a WriterAppender and set the output destination to a newOutputStreamWriterinitialized withosas itsOutputStream.- Parameters:
name- The name of the Appender.layout- The layout to format the message.manager- The OutputStreamManager.
-
AbstractOutputStreamAppender
protected AbstractOutputStreamAppender(String name, Layout<? extends Serializable> layout, Filter filter, boolean ignoreExceptions, boolean immediateFlush, Property[] properties, M manager) Instantiates a WriterAppender and set the output destination to a newOutputStreamWriterinitialized withosas itsOutputStream.- Parameters:
name- The name of the Appender.layout- The layout to format the message.properties- optional propertiesmanager- The OutputStreamManager.
-
-
Method Details
-
getImmediateFlush
public boolean getImmediateFlush()Gets the immediate flush setting.- Returns:
- immediate flush.
-
getManager
Gets the manager.- Returns:
- the manager.
-
start
public void start()Description copied from class:AbstractFilterableMake the Filter available for use.- Specified by:
startin interfaceLifeCycle- Overrides:
startin classAbstractFilterable
-
stop
Description copied from class:AbstractFilterableCleanup the Filter.- Specified by:
stopin interfaceLifeCycle2- Overrides:
stopin classAbstractFilterable- Parameters:
timeout- the maximum time to waittimeUnit- the time unit of the timeout argument- Returns:
- true if the receiver was stopped cleanly and normally, false otherwise.
-
stop
Description copied from class:AbstractFilterableCleanup the Filter.- Overrides:
stopin classAbstractFilterable
-
append
Actual writing occurs here.Most subclasses of
AbstractOutputStreamAppenderwill need to override this method.- Parameters:
event- The LogEvent.
-
tryAppend
-
directEncodeEvent
-
writeByteArrayToManager
-
AbstractOutputStreamAppender(String, Layout, Filter, boolean, boolean, Property[], OutputStreamManager)