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 classRoutingAppender.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 java.lang.StringSTATIC_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 voidappend(LogEvent event)Logs a LogEvent using whatever logic this Appender wishes to use.static RoutingAppendercreateAppender(java.lang.String name, java.lang.String ignore, Routes routes, Configuration config, RewritePolicy rewritePolicy, PurgePolicy purgePolicy, Filter filter)Deprecated.Since 2.7; usenewBuilder()voiddeleteAppender(java.lang.String key)Deletes the specified appender.java.util.Map<java.lang.String,AppenderControl>getAppenders()Returns an unmodifiable view of the appenders created by thisRoutingAppender.ConfigurationgetConfiguration()RoutegetDefaultRoute()AbstractScriptgetDefaultRouteScript()PurgePolicygetPurgePolicy()RewritePolicygetRewritePolicy()RoutesgetRoutes()java.util.concurrent.ConcurrentMap<java.lang.Object,java.lang.Object>getScriptStaticVariables()static <B extends RoutingAppender.Builder<B>>
BnewBuilder()voidstart()Make the Filter available for use.booleanstop(long timeout, java.util.concurrent.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 java.lang.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:AbstractFilterableMake the Filter available for use.- Specified by:
startin interfaceLifeCycle- Overrides:
startin classAbstractFilterable
-
stop
public boolean stop(long timeout, java.util.concurrent.TimeUnit timeUnit)Description copied from class:AbstractFilterableCleanup the Filter.- Specified by:
stopin interfaceLifeCycle2- Overrides:
stopin 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:AppenderLogs 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 java.util.Map<java.lang.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(java.lang.String key)
Deletes the specified appender.- Parameters:
key- The appender's key
-
createAppender
@Deprecated public static RoutingAppender createAppender(java.lang.String name, java.lang.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 java.util.concurrent.ConcurrentMap<java.lang.Object,java.lang.Object> getScriptStaticVariables()
-
-