Class FileRotationHandler


  • public class FileRotationHandler
    extends Handler
    Logging handler logging into a set of rotating files. For each day one file is created. Old files are optionally collected into an archive (not supported yet). Supports the following LogManager configuration properties. If properties are not defined (or have invalid values) then the specified default values are used:
    • com.six.timapi.FileRotationHandler.level specifies the default level for the Handler (defaults to Level.ALL).
    • com.six.timapi.FileRotationHandler.formatter specifies the name of a Formatter class to use (defaults to com.six.timapi.SimpleLineLogFormatter).
    • com.six.timapi.FileRotationHandler.prefix specifies the prefix used for log files (defaults to "TimApi-").
    • com.six.timapi.FileRotationHandler.directory specified the directory to place log files in (defaults to working directory). Directory is not required to exist.
    • com.six.timapi.FileRotationHandler.retainFileCount specifies the number of files to retain on disk before archiving them (defaults to 7).
    • Constructor Detail

      • FileRotationHandler

        public FileRotationHandler​(String directory,
                                   String prefix,
                                   Formatter formatter)
                            throws IOException,
                                   ClassNotFoundException
        Create handler.
        Parameters:
        directory - Directory to create log files in. If null uses LogManager configuration property. If not defined uses working directory.
        prefix - Log file prefix. If null uses LogManager configuration property. If not defined uses "TimApi-".
      • formatter - Formatter to use. If null uses LogManager configuration property. If not defined uses SimpleLineLogFormatter.
        Throws:
        IOException - Log directory can not be created.
        ClassNotFoundException - Formatter class can not be found or instantiated.
    • Method Detail

      • getRetainFileCount

        public int getRetainFileCount()
        Number of log files to keep before archiving them.
      • setRetainFileCount

        public void setRetainFileCount​(int count)
        Set number of log files to keep before archiving them.
      • getFileCountPerArchive

        public int getFileCountPerArchive()
        Number of log files to keep before per archive file.
      • setFileCountPerArchive

        public void setFileCountPerArchive​(int fileCountPerArchive)
        Set number of log files to keep before per archive file.
      • getRetainArchiveCount

        public int getRetainArchiveCount()
        Number of log file archives to keep before deleting them. 0 to disable using archive files.
      • setRetainArchiveCount

        public void setRetainArchiveCount​(int retainArchiveCount)
        Set number of log file archives to keep before deleting them. Use 0 to disable using archive files.
      • getNewFileHeader

        public String getNewFileHeader()
        Header written to newly created log files after rotation. Use null to disable.
      • setNewFileHeader

        public void setNewFileHeader​(String newFileHeader)
        Header written to newly created log files after rotation. Use null to disable.
      • close

        public void close()
        Close handler.
        Specified by:
        close in class Handler
      • flush

        public void flush()
        Flush handler.
        Specified by:
        flush in class Handler