Class BoundedPurgePolicy

  • All Implemented Interfaces:
    org.apache.logging.log4j.core.appender.routing.PurgePolicy, org.apache.logging.log4j.core.LifeCycle, org.apache.logging.log4j.core.LifeCycle2

    @Plugin(name="BoundedPurgePolicy",
            category="Core",
            printObject=true)
    public class BoundedPurgePolicy
    extends org.apache.logging.log4j.core.AbstractLifeCycle
    implements org.apache.logging.log4j.core.appender.routing.PurgePolicy
    Policy is purging appenders that were not in use specified time, or sooner if there are too many active appenders
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle

        org.apache.logging.log4j.core.LifeCycle.State
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String VALUE  
      • Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle

        DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static org.apache.logging.log4j.core.appender.routing.PurgePolicy createPurgePolicy​(int size, String excludePrefix)
      Create the PurgePolicy
      void initialize​(org.apache.logging.log4j.core.appender.routing.RoutingAppender routingAppender)  
      void purge()
      Delete the oldest appenders (sorted by their last access time) until there are maxSize appenders or less.
      boolean stop​(long timeout, TimeUnit timeUnit)  
      String toString()  
      void update​(String key, org.apache.logging.log4j.core.LogEvent event)  
      • 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, start, stop, stop
    • Constructor Detail

      • BoundedPurgePolicy

        public BoundedPurgePolicy​(int maxSize,
                                  String excludePrefix)
    • Method Detail

      • initialize

        public void initialize​(org.apache.logging.log4j.core.appender.routing.RoutingAppender routingAppender)
        Specified by:
        initialize in interface org.apache.logging.log4j.core.appender.routing.PurgePolicy
      • stop

        public boolean stop​(long timeout,
                            TimeUnit timeUnit)
        Specified by:
        stop in interface org.apache.logging.log4j.core.LifeCycle2
        Overrides:
        stop in class org.apache.logging.log4j.core.AbstractLifeCycle
      • purge

        public void purge()
        Delete the oldest appenders (sorted by their last access time) until there are maxSize appenders or less.
        Specified by:
        purge in interface org.apache.logging.log4j.core.appender.routing.PurgePolicy
      • update

        public void update​(String key,
                           org.apache.logging.log4j.core.LogEvent event)
        Specified by:
        update in interface org.apache.logging.log4j.core.appender.routing.PurgePolicy
      • createPurgePolicy

        @PluginFactory
        public static org.apache.logging.log4j.core.appender.routing.PurgePolicy createPurgePolicy​(@PluginAttribute("size")
                                                                                                   int size,
                                                                                                   @PluginAttribute(value="excludePrefix",defaultString="${")
                                                                                                   String excludePrefix)
        Create the PurgePolicy
        Parameters:
        size - the maximum number of appenders to keep active at any moment
        excludePrefix - a prefix to exclude from eviction, defaults to "${" for missing key.
        Returns:
        The Routes container.