Class AbstractWriterAppender<M extends WriterManager>
- 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.AbstractWriterAppender<M>
-
- Type Parameters:
M
- The kind ofWriterManager
under management
- All Implemented Interfaces:
Appender
,Filterable
,LocationAware
,LifeCycle
,LifeCycle2
- Direct Known Subclasses:
WriterAppender
public abstract class AbstractWriterAppender<M extends WriterManager> extends AbstractAppender
Appends log events as strings to a writer.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.logging.log4j.core.appender.AbstractAppender
AbstractAppender.Builder<B extends AbstractAppender.Builder<B>>
-
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
LifeCycle.State
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
immediateFlush
Immediate flush means that the underlying writer will be flushed at the end of each append operation.-
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
AbstractWriterAppender(String name, StringLayout layout, Filter filter, boolean ignoreExceptions, boolean immediateFlush, M manager)
protected
AbstractWriterAppender(String name, StringLayout layout, Filter filter, boolean ignoreExceptions, boolean immediateFlush, Property[] properties, M manager)
Instantiates.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(LogEvent event)
Actual writing occurs here.M
getManager()
Gets the manager.StringLayout
getStringLayout()
void
start()
Make the Filter available for use.boolean
stop(long timeout, TimeUnit timeUnit)
Cleanup the Filter.-
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, stop
-
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
-
-
-
-
Field Detail
-
immediateFlush
protected final boolean immediateFlush
Immediate flush means that the underlying writer will be flushed at the end of each append operation. Immediate flush is slower but ensures that each append request is actually written. IfimmediateFlush
is 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.
-
-
Constructor Detail
-
AbstractWriterAppender
protected AbstractWriterAppender(String name, StringLayout layout, Filter filter, boolean ignoreExceptions, boolean immediateFlush, Property[] properties, M manager)
Instantiates.- Parameters:
name
- The name of the Appender.layout
- The layout to format the message.properties
- Optional properties.manager
- The OutputStreamManager.
-
AbstractWriterAppender
@Deprecated protected AbstractWriterAppender(String name, StringLayout layout, Filter filter, boolean ignoreExceptions, boolean immediateFlush, M manager)
Deprecated.Instantiates.- Parameters:
name
- The name of the Appender.layout
- The layout to format the message.manager
- The OutputStreamManager.
-
-
Method Detail
-
append
public void append(LogEvent event)
Actual writing occurs here.Most subclasses will need to override this method.
- Parameters:
event
- The LogEvent.
-
getManager
public M getManager()
Gets the manager.- Returns:
- the manager.
-
getStringLayout
public StringLayout getStringLayout()
-
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.
-
-