Class RotatingFileTarget

All Implemented Interfaces:
ErrorAware, LogTarget, Closeable

public class RotatingFileTarget extends FileTarget
This is a basic Output log target that writes to rotating files.
Author:
Peter Donald, Stephen McConnell, Bernhard Huber
  • Field Details

    • m_append

      private boolean m_append
    • m_rotateStrategy

      private RotateStrategy m_rotateStrategy
    • m_fileStrategy

      private FileStrategy m_fileStrategy
  • Constructor Details

    • RotatingFileTarget

      public RotatingFileTarget(Formatter formatter, RotateStrategy rotateStrategy, FileStrategy fileStrategy) throws IOException
      Construct RotatingFileTarget object.
      Parameters:
      formatter - Formatter to be used
      rotateStrategy - RotateStrategy to be used
      fileStrategy - FileStrategy to be used
      Throws:
      IOException - if a file access or write related error occurs
    • RotatingFileTarget

      public RotatingFileTarget(boolean append, Formatter formatter, RotateStrategy rotateStrategy, FileStrategy fileStrategy) throws IOException
      Construct RotatingFileTarget object.
      Parameters:
      append - true if file is to be appended to, false otherwise
      formatter - Formatter to be used
      rotateStrategy - RotateStrategy to be used
      fileStrategy - FileStrategy to be used
      Throws:
      IOException - if a file access or write related error occurs
  • Method Details

    • rotate

      protected void rotate() throws IOException
      Rotates the file.
      Throws:
      IOException - if a file access or write related error occurs
    • write

      protected void write(String data)
      Output the log message, and check if rotation is needed.
      Overrides:
      write in class StreamTarget
      Parameters:
      data - the date to write to the target