Class SizeBasedTriggeringPolicy

  • All Implemented Interfaces:
    TriggeringPolicy, org.apache.log4j.spi.OptionHandler

    public final class SizeBasedTriggeringPolicy
    extends java.lang.Object
    implements TriggeringPolicy, org.apache.log4j.spi.OptionHandler
    SizeBasedTriggeringPolicy looks at size of the file being currently written to.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private long maxFileSize
      Rollover threshold size in bytes.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void activateOptions()
      Prepares policy for use.
      long getMaxFileSize()
      Gets rollover threshold size in bytes.
      boolean isTriggeringEvent​(org.apache.log4j.Appender appender, org.apache.log4j.spi.LoggingEvent event, java.lang.String file, long fileLength)
      Determines if a rollover may be appropriate at this time.
      void setMaxFileSize​(long l)
      Sets rollover threshold size in bytes.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • maxFileSize

        private long maxFileSize
        Rollover threshold size in bytes.
    • Constructor Detail

      • SizeBasedTriggeringPolicy

        public SizeBasedTriggeringPolicy()
        Constructs a new instance.
      • SizeBasedTriggeringPolicy

        public SizeBasedTriggeringPolicy​(long maxFileSize)
        Constructs an new instance.
        Parameters:
        maxFileSize - rollover threshold size in bytes.
    • Method Detail

      • isTriggeringEvent

        public boolean isTriggeringEvent​(org.apache.log4j.Appender appender,
                                         org.apache.log4j.spi.LoggingEvent event,
                                         java.lang.String file,
                                         long fileLength)
        Determines if a rollover may be appropriate at this time. If true is returned, RolloverPolicy.rollover will be called but it can determine that a rollover is not warranted.
        Specified by:
        isTriggeringEvent in interface TriggeringPolicy
        Parameters:
        appender - A reference to the appender.
        event - A reference to the currently event.
        file - The filename for the currently active log file.
        fileLength - Length of the file in bytes.
        Returns:
        true if a rollover should occur.
      • getMaxFileSize

        public long getMaxFileSize()
        Gets rollover threshold size in bytes.
        Returns:
        rollover threshold size in bytes.
      • setMaxFileSize

        public void setMaxFileSize​(long l)
        Sets rollover threshold size in bytes.
        Parameters:
        l - new value for rollover threshold size.
      • activateOptions

        public void activateOptions()
        Prepares policy for use.
        Specified by:
        activateOptions in interface org.apache.log4j.spi.OptionHandler