Class RotatingFileAppender

    • Constructor Detail

      • RotatingFileAppender

        public RotatingFileAppender​(File directory,
                                    String filePattern)
                             throws IOException
        Create a RotatingFileAppender writing access log files in the specified directory and using the specified SimpleDateFormat pattern to generate file names.

        For example when the specified pattern is 'access-'yyyyMMDDhh'.log' (note the quotes), access log files will be rotated on a hourly basis, and the output will be written to files like access-2013120422.log, access-2013120423.log, ... and so on.

        Parameters:
        directory - The directory where access log files will be written to.
        filePattern - A properly escaped SimpleDateFormat pattern for the access log files.
        Throws:
        IOException - If an I/O error occurred accessing the filesystem.
      • RotatingFileAppender

        public RotatingFileAppender​(File directory,
                                    String fileName,
                                    String archivePattern)
                             throws IOException
        Create a RotatingFileAppender writing access log files in the specified directory.

        When using this constructor the current log file (the one being written to) will always be the one identified by the fileName parameter, and then archival of files will be delegated to the archive pattern.

        For example when fileName is current.log and archivePattern is 'archive-'yyyyMMDD'.log' (note the quotes), access logs will be written to the current.log file and this file will be rotated on a daily basis to files like archive-20131204.log, archive-20131205.log, ... and so on.

        Parameters:
        directory - The directory where access log files will be written to.
        fileName - A file name where log entries will be written to.
        archivePattern - A properly escaped SimpleDateFormat pattern for the access log archive files.
        Throws:
        IOException - If an I/O error occurred accessing the filesystem.