Class 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.
  • Field Details

  • Method Details

    • 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 interface LifeCycle
      Overrides:
      start in class AbstractFilterable
    • stop

      public boolean stop(long timeout, TimeUnit timeUnit)
      Description copied from class: AbstractFilterable
      Cleanup the Filter.
      Specified by:
      stop in interface LifeCycle2
      Overrides:
      stop in class AbstractFilterable
      Parameters:
      timeout - the maximum time to wait
      timeUnit - 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 this RoutingAppender. 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; use newBuilder()
      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()