Class PeriodicRotatingFileHandler

    • Constructor Detail

      • PeriodicRotatingFileHandler

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

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

        public PeriodicRotatingFileHandler​(java.lang.String fileName,
                                           boolean append)
                                    throws java.io.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:
        java.io.FileNotFoundException - if the file could not be found on open
      • PeriodicRotatingFileHandler

        public PeriodicRotatingFileHandler​(java.io.File file,
                                           java.lang.String suffix)
                                    throws java.io.FileNotFoundException
        Construct a new instance with the given output file.
        Parameters:
        file - the file
        suffix - the format suffix to use
        Throws:
        java.io.FileNotFoundException - if the file could not be found on open
      • PeriodicRotatingFileHandler

        public PeriodicRotatingFileHandler​(java.io.File file,
                                           java.lang.String suffix,
                                           boolean append)
                                    throws java.io.FileNotFoundException
        Construct a new instance with the given output file and append setting.
        Parameters:
        file - the file
        suffix - the format suffix to use
        append - true to append, false to overwrite
        Throws:
        java.io.FileNotFoundException - if the file could not be found on open
    • Method Detail

      • setFile

        public void setFile​(java.io.File file)
                     throws java.io.FileNotFoundException
        Description copied from class: FileHandler
        Set the output file.
        Overrides:
        setFile in class FileHandler
        Parameters:
        file - the file
        Throws:
        java.io.FileNotFoundException - if an error occurs opening the file
      • 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. This implementation checks to see if the scheduled rollover time has yet occurred.
        Overrides:
        preWrite in class WriterHandler
        Parameters:
        record - the record about to be logged
      • setSuffix

        public void setSuffix​(java.lang.String suffix)
                       throws java.lang.IllegalArgumentException
        Set the suffix string. The string is in a format which can be understood by SimpleDateFormat. The period of the rotation is automatically calculated based on the suffix.

        If the suffix ends with .gz or .zip the file will be compressed on rotation.

        Parameters:
        suffix - the suffix
        Throws:
        java.lang.IllegalArgumentException - if the suffix is not valid
      • getNextSuffix

        protected final java.lang.String getNextSuffix()
        Returns the suffix to be used.
        Returns:
        the suffix to be used
      • getTimeZone

        public java.util.TimeZone getTimeZone()
        Get the configured time zone for this handler.
        Returns:
        the configured time zone
      • setTimeZone

        public void setTimeZone​(java.util.TimeZone timeZone)
        Set the configured time zone for this handler.
        Parameters:
        timeZone - the configured time zone