Class RollingFileManager

All Implemented Interfaces:
AutoCloseable, ByteBufferDestination
Direct Known Subclasses:
RollingRandomAccessFileManager

public class RollingFileManager extends FileManager
The Rolling File Manager.
  • Field Details

    • size

      protected long size
  • Constructor Details

  • Method Details

    • initialize

      public void initialize()
    • getFileManager

      public static RollingFileManager getFileManager(String fileName, String pattern, boolean append, boolean bufferedIO, TriggeringPolicy policy, RolloverStrategy strategy, String advertiseURI, Layout<? extends Serializable> layout, int bufferSize, boolean immediateFlush, boolean createOnDemand, String filePermissions, String fileOwner, String fileGroup, Configuration configuration)
      Returns a RollingFileManager.
      Parameters:
      fileName - The file name.
      pattern - The pattern for rolling file.
      append - true if the file should be appended to.
      bufferedIO - true if data should be buffered.
      policy - The TriggeringPolicy.
      strategy - The RolloverStrategy.
      advertiseURI - the URI to use when advertising the file
      layout - The Layout.
      bufferSize - buffer size to use if bufferedIO is true
      immediateFlush - flush on every write or not
      createOnDemand - true if you want to lazy-create the file (a.k.a. on-demand.)
      filePermissions - File permissions
      fileOwner - File owner
      fileGroup - File group
      configuration - The configuration.
      Returns:
      A RollingFileManager.
    • addRolloverListener

      public void addRolloverListener(RolloverListener listener)
      Add a RolloverListener.
      Parameters:
      listener - The RolloverListener.
    • removeRolloverListener

      public void removeRolloverListener(RolloverListener listener)
      Remove a RolloverListener.
      Parameters:
      listener - The RolloverListener.
    • getFileName

      public String getFileName()
      Returns the name of the File being managed.
      Overrides:
      getFileName in class FileManager
      Returns:
      The name of the File being managed.
    • createParentDir

      protected void createParentDir(File file)
      Overrides:
      createParentDir in class FileManager
    • isDirectWrite

      public boolean isDirectWrite()
    • getFileExtension

      public FileExtension getFileExtension()
    • write

      protected void write(byte[] bytes, int offset, int length, boolean immediateFlush)
      Description copied from class: OutputStreamManager
      Some output streams synchronize writes while others do not. Synchronizing here insures that log events won't be intertwined.
      Overrides:
      write in class FileManager
      Parameters:
      bytes - The serialized Log event.
      offset - The offset into the byte array.
      length - The number of bytes to write.
      immediateFlush - flushes immediately after writing.
    • writeToDestination

      protected void writeToDestination(byte[] bytes, int offset, int length)
      Description copied from class: FileManager
      Overrides OutputStreamManager.writeToDestination(byte[], int, int) to add support for file locking.
      Overrides:
      writeToDestination in class FileManager
      Parameters:
      bytes - the array containing data
      offset - from where to write
      length - how many bytes to write
    • isRenameEmptyFiles

      public boolean isRenameEmptyFiles()
    • setRenameEmptyFiles

      public void setRenameEmptyFiles(boolean renameEmptyFiles)
    • getFileSize

      public long getFileSize()
      Returns the current size of the file.
      Returns:
      The size of the file in bytes.
    • getFileTime

      public long getFileTime()
      Returns the time the file was created.
      Returns:
      The time the file was created.
    • checkRollover

      public void checkRollover(LogEvent event)
      Determines if a rollover should occur.
      Parameters:
      event - The LogEvent.
    • releaseSub

      public boolean releaseSub(long timeout, TimeUnit timeUnit)
      Description copied from class: OutputStreamManager
      Default hook to write footer during close.
      Overrides:
      releaseSub in class OutputStreamManager
      Parameters:
      timeout - timeout
      timeUnit - timeout time unit
      Returns:
      true if all resources were closed normally, false otherwise.
    • rollover

      public void rollover(Date prevFileTime, Date prevRollTime)
    • rollover

      public void rollover()
    • createFileAfterRollover

      protected void createFileAfterRollover() throws IOException
      Throws:
      IOException
    • getPatternProcessor

      public PatternProcessor getPatternProcessor()
      Returns the pattern processor.
      Returns:
      The PatternProcessor.
    • setTriggeringPolicy

      public void setTriggeringPolicy(TriggeringPolicy triggeringPolicy)
    • setRolloverStrategy

      public void setRolloverStrategy(RolloverStrategy rolloverStrategy)
    • setPatternProcessor

      public void setPatternProcessor(PatternProcessor patternProcessor)
    • getTriggeringPolicy

      public <T extends TriggeringPolicy> T getTriggeringPolicy()
      Returns the triggering policy.
      Type Parameters:
      T - TriggeringPolicy type
      Returns:
      The TriggeringPolicy
    • getRolloverStrategy

      public RolloverStrategy getRolloverStrategy()
      Returns the rollover strategy.
      Returns:
      The RolloverStrategy
    • updateData

      public void updateData(Object data)
      Updates the RollingFileManager's data during a reconfiguration. This method should be considered private. It is not thread safe and calling it outside of a reconfiguration may lead to errors. This method may be made protected in a future release.
      Overrides:
      updateData in class AbstractManager
      Parameters:
      data - The data to update.