Class RotatingFileLoggerOutput

java.lang.Object
org.omegazero.common.logging.FileLoggerOutput
org.omegazero.common.logging.RotatingFileLoggerOutput
All Implemented Interfaces:
LoggerOutput

public class RotatingFileLoggerOutput extends FileLoggerOutput
A FileLoggerOutput with support for log rotation.
Since:
2.11.0
  • Field Details

    • MAX_FILE_SIZE_DEFAULT

      public static final long MAX_FILE_SIZE_DEFAULT
      System property org.omegazero.common.logging.rotation.maxFileSize

      The default maximum file size for rotation.

      Default: 0 (log rotation disabled)

    • CHECK_TIMEOUT

      public static final long CHECK_TIMEOUT
      System property org.omegazero.common.logging.rotation.checkTimeout

      The time in seconds between rotation checks.

      Default: 60

  • Constructor Details

    • RotatingFileLoggerOutput

      public RotatingFileLoggerOutput(String logFile, long maxFileSize) throws IOException
      Creates a new RotatingFileLoggerOutput, writing to the given logFile.
      Parameters:
      logFile - The name of the output log file
      maxFileSize - The maximum file size for rotation. If this value is negative, the default is used; if 0, log rotation is disabled
      Throws:
      IOException - If an IO error occurs while opening the file
      See Also:
    • RotatingFileLoggerOutput

      public RotatingFileLoggerOutput(String logFile, long maxFileSize, int logBufferBytes, int saveInterval) throws IOException
      Creates a new RotatingFileLoggerOutput, writing to the given logFile.

      The maximum file size parameter is not a hard limit on the file size of log files. If the log file exceeds this size, it is rotated, but the file may end up larger than this parameter, especially if there is a lot of log output in a short time.

      Parameters:
      logFile - The name of the output log file
      maxFileSize - The maximum file size for rotation. If this value is negative, the default is used; if 0, log rotation is disabled
      logBufferBytes - The size of the internal log data buffer
      saveInterval - The save interval
      Throws:
      IOException - If an IO error occurs while opening the file
      See Also:
  • Method Details