Class FileLogger

  • All Implemented Interfaces:
    Logger

    public class FileLogger
    extends AbstractLogger
    Outputs log information into a file.

    Clients may instantiate or subclass this class.

    • Constructor Detail

      • FileLogger

        public FileLogger​(File file)
                   throws FileNotFoundException
        Constructs a logger which outputs log information into the specified file.

        If the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason then a FileNotFoundException is thrown.

        Parameters:
        file - the file where to log information.
        Throws:
        FileNotFoundException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason.
      • FileLogger

        public FileLogger​(File file,
                          boolean append)
                   throws FileNotFoundException
        Constructs a logger which outputs log information into the specified file.

        If the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason then a FileNotFoundException is thrown.

        Parameters:
        file - the file where to log information.
        append - if true, then information will be written to the end of the file rather than the beginning.
        Throws:
        FileNotFoundException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason.
    • Method Detail

      • log

        protected void log​(Level level,
                           Object message,
                           Throwable error)
        Appends the specified message and error to the underlying file. This default implementation always output information the same way, whatever the log level is.
        Specified by:
        log in class AbstractLogger
        Parameters:
        level - the log level (not considered by the implementation).
        message - the information to log (usually a String), maybe null.
        error - an exception to log, maybe null.