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
Nested Classes Modifier and Type Class Description static 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 Modifier and Type Field Description static String
STATIC_VARIABLES_KEY
-
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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
append(LogEvent event)
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.Since 2.7; usenewBuilder()
void
deleteAppender(String key)
Deletes the specified appender.Map<String,AppenderControl>
getAppenders()
Returns an unmodifiable view of the appenders created by thisRoutingAppender
.Configuration
getConfiguration()
Route
getDefaultRoute()
AbstractScript
getDefaultRouteScript()
PurgePolicy
getPurgePolicy()
RewritePolicy
getRewritePolicy()
Routes
getRoutes()
ConcurrentMap<Object,Object>
getScriptStaticVariables()
static <B extends RoutingAppender.Builder<B>>
BnewBuilder()
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
-
STATIC_VARIABLES_KEY
public static final String STATIC_VARIABLES_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
newBuilder
@PluginBuilderFactory public static <B extends RoutingAppender.Builder<B>> B 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
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.
-
append
public void append(LogEvent event)
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
public Map<String,AppenderControl> 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
public void deleteAppender(String key)
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
public Route getDefaultRoute()
-
getDefaultRouteScript
public AbstractScript getDefaultRouteScript()
-
getPurgePolicy
public PurgePolicy getPurgePolicy()
-
getRewritePolicy
public RewritePolicy getRewritePolicy()
-
getRoutes
public Routes getRoutes()
-
getConfiguration
public Configuration getConfiguration()
-
getScriptStaticVariables
public ConcurrentMap<Object,Object> getScriptStaticVariables()
-
-