Class SizeRotatingFileHandler

    • Constructor Detail

      • SizeRotatingFileHandler

        public SizeRotatingFileHandler()
        Construct a new instance with no formatter and no output file.
      • SizeRotatingFileHandler

        public SizeRotatingFileHandler​(File file)
                                throws FileNotFoundException
        Construct a new instance with the given output file.
        Parameters:
        file - the file
        Throws:
        FileNotFoundException - if the file could not be found on open
      • SizeRotatingFileHandler

        public SizeRotatingFileHandler​(File file,
                                       boolean append)
                                throws FileNotFoundException
        Construct a new instance with the given output file and append setting.
        Parameters:
        file - the file
        append - true to append, false to overwrite
        Throws:
        FileNotFoundException - if the file could not be found on open
      • SizeRotatingFileHandler

        public SizeRotatingFileHandler​(String fileName)
                                throws FileNotFoundException
        Construct a new instance with the given output file.
        Parameters:
        fileName - the file name
        Throws:
        FileNotFoundException - if the file could not be found on open
      • SizeRotatingFileHandler

        public SizeRotatingFileHandler​(String fileName,
                                       boolean append)
                                throws FileNotFoundException
        Construct a new instance with the given output file and append setting.
        Parameters:
        fileName - the file name
        append - true to append, false to overwrite
        Throws:
        FileNotFoundException - if the file could not be found on open
      • SizeRotatingFileHandler

        public SizeRotatingFileHandler​(long rotateSize,
                                       int maxBackupIndex)
        Construct a new instance with no formatter and no output file.
      • SizeRotatingFileHandler

        public SizeRotatingFileHandler​(File file,
                                       long rotateSize,
                                       int maxBackupIndex)
                                throws FileNotFoundException
        Construct a new instance with the given output file.
        Parameters:
        file - the file
        Throws:
        FileNotFoundException - if the file could not be found on open
      • SizeRotatingFileHandler

        public SizeRotatingFileHandler​(File file,
                                       boolean append,
                                       long rotateSize,
                                       int maxBackupIndex)
                                throws FileNotFoundException
        Construct a new instance with the given output file and append setting.
        Parameters:
        file - the file
        append - true to append, false to overwrite
        Throws:
        FileNotFoundException - if the file could not be found on open
    • Method Detail

      • setOutputStream

        public void setOutputStream​(OutputStream outputStream)
        Set the output stream to write to.
        Overrides:
        setOutputStream in class OutputStreamHandler
        Parameters:
        outputStream - the new output stream or null for none
      • isRotateOnBoot

        public boolean isRotateOnBoot()
        Indicates whether or a not the handler should rotate the file before the first log record is written.
        Returns:
        true if file should rotate on boot, otherwise false/
      • setRotateOnBoot

        public void setRotateOnBoot​(boolean rotateOnBoot)
        Set to a value of true if the file should be rotated before the a new file is set. The rotation only happens if the file names are the same and the file has a length greater than 0.
        Parameters:
        rotateOnBoot - true to rotate on boot, otherwise false
      • setRotateSize

        public void setRotateSize​(long rotateSize)
        Set the rotation size, in bytes.
        Parameters:
        rotateSize - the number of bytes before the log is rotated
      • setMaxBackupIndex

        public void setMaxBackupIndex​(int maxBackupIndex)
        Set the maximum backup index (the number of log files to keep around).
        Parameters:
        maxBackupIndex - the maximum backup index
      • getSuffix

        public String getSuffix()
        Returns the suffix set to be appended to files during rotation.
        Returns:
        the suffix or null if no suffix should be used
      • setSuffix

        public void setSuffix​(String suffix)
        Sets the suffix to be appended to the file name during the file rotation. The suffix does not play a role in determining when the file should be rotated.

        The suffix must be a string understood by the SimpleDateFormat.

        Note: Any files rotated with the suffix appended will not be deleted. The maxBackupIndex is not used for files with a suffix.

        Parameters:
        suffix - the suffix to place after the filename when the file is rotated
      • preWrite

        protected void preWrite​(ExtLogRecord record)
        Execute any pre-write policy, such as file rotation. The write lock is held during this method, so make it quick. The default implementation does nothing.
        Overrides:
        preWrite in class WriterHandler
        Parameters:
        record - the record about to be logged