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 ofOutputStreamManager
under 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 Classes Modifier and Type Class Description static class
AbstractOutputStreamAppender.Builder<B extends AbstractOutputStreamAppender.Builder<B>>
Subclasses can extend this abstract Builder.-
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
LifeCycle.State
-
-
Field Summary
-
Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
-
Fields inherited from interface org.apache.logging.log4j.core.Appender
ELEMENT_TYPE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractOutputStreamAppender(String name, Layout<? extends Serializable> layout, Filter filter, boolean ignoreExceptions, boolean immediateFlush, M manager)
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 newOutputStreamWriter
initialized withos
as itsOutputStream
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(LogEvent event)
Actual writing occurs here.protected void
directEncodeEvent(LogEvent event)
boolean
getImmediateFlush()
Gets the immediate flush setting.M
getManager()
Gets the manager.void
start()
Make the Filter available for use.boolean
stop(long timeout, TimeUnit timeUnit)
Cleanup the Filter.protected boolean
stop(long timeout, TimeUnit timeUnit, boolean changeLifeCycleState)
Cleanup the Filter.protected void
writeByteArrayToManager(LogEvent event)
-
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractAppender
error, error, error, getHandler, getLayout, getName, ignoreExceptions, parseInt, requiresLocation, setHandler, toSerializable, toString
-
Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilterable
addFilter, getFilter, getPropertyArray, hasFilter, isFiltered, removeFilter
-
Methods 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
-
-
-
-
Constructor Detail
-
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 newOutputStreamWriter
initialized withos
as 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 newOutputStreamWriter
initialized withos
as itsOutputStream
.- Parameters:
name
- The name of the Appender.layout
- The layout to format the message.properties
- optional propertiesmanager
- The OutputStreamManager.
-
-
Method Detail
-
getImmediateFlush
public boolean getImmediateFlush()
Gets the immediate flush setting.- Returns:
- immediate flush.
-
getManager
public M getManager()
Gets the manager.- Returns:
- the manager.
-
start
public void start()
Description copied from class:AbstractFilterable
Make the Filter available for use.- Specified by:
start
in interfaceLifeCycle
- Overrides:
start
in classAbstractFilterable
-
stop
public boolean stop(long timeout, TimeUnit timeUnit)
Description copied from class:AbstractFilterable
Cleanup the Filter.- Specified by:
stop
in interfaceLifeCycle2
- Overrides:
stop
in 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
protected boolean stop(long timeout, TimeUnit timeUnit, boolean changeLifeCycleState)
Description copied from class:AbstractFilterable
Cleanup the Filter.- Overrides:
stop
in classAbstractFilterable
-
append
public void append(LogEvent event)
Actual writing occurs here.Most subclasses of
AbstractOutputStreamAppender
will need to override this method.- Parameters:
event
- The LogEvent.
-
directEncodeEvent
protected void directEncodeEvent(LogEvent event)
-
writeByteArrayToManager
protected void writeByteArrayToManager(LogEvent event)
-
-