@Plugin(name="Failover", category="Core", elementType="appender", printObject=true) public final class FailoverAppender extends AbstractAppender
AbstractAppender.Builder<B extends AbstractAppender.Builder<B>>
LifeCycle.State
Modifier and Type | Field and Description |
---|---|
private Configuration |
config |
private static int |
DEFAULT_INTERVAL_SECONDS |
private java.util.List<AppenderControl> |
failoverAppenders |
private java.lang.String[] |
failovers |
private long |
intervalNanos |
private long |
nextCheckNanos |
private AppenderControl |
primary |
private java.lang.String |
primaryRef |
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
ELEMENT_TYPE
Modifier | Constructor and Description |
---|---|
private |
FailoverAppender(java.lang.String name,
Filter filter,
java.lang.String primary,
java.lang.String[] failovers,
int intervalMillis,
Configuration config,
boolean ignoreExceptions,
Property[] properties) |
Modifier and Type | Method and Description |
---|---|
void |
append(LogEvent event)
Handle the Log event.
|
private void |
callAppender(LogEvent event) |
static FailoverAppender |
createAppender(java.lang.String name,
java.lang.String primary,
java.lang.String[] failovers,
java.lang.String retryIntervalSeconds,
Configuration config,
Filter filter,
java.lang.String ignore)
Create a Failover Appender.
|
private void |
failover(LogEvent event,
java.lang.Exception ex) |
void |
start()
Make the Filter available for use.
|
java.lang.String |
toString() |
error, error, error, getHandler, getLayout, getName, ignoreExceptions, parseInt, requiresLocation, setHandler, toSerializable
addFilter, getFilter, getPropertyArray, hasFilter, isFiltered, removeFilter, stop, stop
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stop
private static final int DEFAULT_INTERVAL_SECONDS
private final java.lang.String primaryRef
private final java.lang.String[] failovers
private final Configuration config
private AppenderControl primary
private final java.util.List<AppenderControl> failoverAppenders
private final long intervalNanos
private volatile long nextCheckNanos
private FailoverAppender(java.lang.String name, Filter filter, java.lang.String primary, java.lang.String[] failovers, int intervalMillis, Configuration config, boolean ignoreExceptions, Property[] properties)
public void start()
AbstractFilterable
start
in interface LifeCycle
start
in class AbstractFilterable
public void append(LogEvent event)
event
- The LogEvent.private void callAppender(LogEvent event)
private void failover(LogEvent event, java.lang.Exception ex)
public java.lang.String toString()
toString
in class AbstractAppender
@PluginFactory public static FailoverAppender createAppender(@PluginAttribute(value="name") java.lang.String name, @PluginAttribute(value="primary") java.lang.String primary, @PluginElement(value="Failovers") java.lang.String[] failovers, @PluginAliases(value="retryInterval") @PluginAttribute(value="retryIntervalSeconds") java.lang.String retryIntervalSeconds, @PluginConfiguration Configuration config, @PluginElement(value="Filter") Filter filter, @PluginAttribute(value="ignoreExceptions") java.lang.String ignore)
name
- The name of the Appender (required).primary
- The name of the primary Appender (required).failovers
- The name of one or more Appenders to fail over to (at least one is required).retryIntervalSeconds
- The retry interval in seconds.config
- The current Configuration (passed by the Configuration when the appender is created).filter
- A Filter (optional).ignore
- If "true"
(default) exceptions encountered when appending events are logged; otherwise
they are propagated to the caller.