Class RoutingAppender
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.routing.RoutingAppender
- All Implemented Interfaces:
Appender
,Filterable
,LocationAware
,LifeCycle
,LifeCycle2
@Plugin(name="Routing",
category="Core",
elementType="appender",
printObject=true)
public final class RoutingAppender
extends AbstractAppender
This Appender "routes" between various Appenders, some of which can be references to
Appenders defined earlier in the configuration while others can be dynamically created
within this Appender as required. Routing is achieved by specifying a pattern on
the Routing appender declaration. The pattern should contain one or more substitution patterns of
the form "$${[key:]token}". The pattern will be resolved each time the Appender is called using
the built in StrSubstitutor and the StrLookup plugin that matches the specified key.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
RoutingAppender.Builder<B extends RoutingAppender.Builder<B>>
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, EMPTY_ARRAY
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Logs a LogEvent using whatever logic this Appender wishes to use.static RoutingAppender
createAppender
(String name, String ignore, Routes routes, Configuration config, RewritePolicy rewritePolicy, PurgePolicy purgePolicy, Filter filter) Deprecated.void
deleteAppender
(String key) Deletes the specified appender.Returns an unmodifiable view of the appenders created by thisRoutingAppender
.static <B extends RoutingAppender.Builder<B>>
Bvoid
start()
Make the Filter available for use.boolean
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 Details
-
STATIC_VARIABLES_KEY
- See Also:
-
-
Method Details
-
newBuilder
-
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
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.
-
append
Description copied from interface:Appender
Logs a LogEvent using whatever logic this Appender wishes to use. It is typically recommended to use a bridge pattern not only for the benefits from decoupling an Appender from its implementation, but it is also handy for sharing resources which may require some form of locking.- Parameters:
event
- The LogEvent.
-
getAppenders
Returns an unmodifiable view of the appenders created by thisRoutingAppender
. Note that this map does not contain appenders that are routed by reference. -
deleteAppender
Deletes the specified appender.- Parameters:
key
- The appender's key
-
createAppender
@Deprecated public static RoutingAppender createAppender(String name, String ignore, Routes routes, Configuration config, RewritePolicy rewritePolicy, PurgePolicy purgePolicy, Filter filter) Deprecated.Since 2.7; usenewBuilder()
Creates a RoutingAppender.- Parameters:
name
- The name of the Appender.ignore
- If"true"
(default) exceptions encountered when appending events are logged; otherwise they are propagated to the caller.routes
- The routing definitions.config
- The Configuration (automatically added by the Configuration).rewritePolicy
- A RewritePolicy, if any.filter
- A Filter to restrict events processed by the Appender or null.- Returns:
- The RoutingAppender
-
getDefaultRoute
-
getDefaultRouteScript
-
getPurgePolicy
-
getRewritePolicy
-
getRoutes
-
getConfiguration
-
getScriptStaticVariables
-
newBuilder()