Class FileHandler

  • All Implemented Interfaces:
    Direct Known Subclasses:

    public class FileHandler
    extends AbstractLogHandler
    Sends all logging output to the specified log file.
    Makes use of the ADAMS_LOGFILE_PREFIX environment variable. E.g., with "ADAMS_LOGFILE_PREFIX=testing-", the default log file "$HOME/.adams/log/console.log" will become "$HOME/.adams/log/testing-console.log".
    fracpete (fracpete at waikato dot ac dot nz)
    • Field Detail


        public static final String ADAMS_LOGFILE_PREFIX
        the environment variable to inject a prefix into the log file.
        See Also:
        Constant Field Values
      • m_LogFile

        protected File m_LogFile
        the log file to use.
      • m_LogIsDir

        protected boolean m_LogIsDir
        whether the file points to a directory.
    • Constructor Detail

      • FileHandler

        public FileHandler()
    • Method Detail

      • setLogFile

        public void setLogFile​(File value)
        Sets the log file to use.
        value - the file
      • getLogFile

        public File getLogFile()
        Returns the log file in use.
        the file
      • setUp

        protected void setUp()
        Hook method for performing setup before processing first log record.
        setUp in class AbstractLogHandler
      • doPublish

        protected void doPublish​(LogRecord record)
        Publish a LogRecord.

        The logging request was made initially to a Logger object, which initialized the LogRecord and forwarded it here.

        The Handler is responsible for formatting the message, when and if necessary. The formatting should include localization.

        Specified by:
        doPublish in class AbstractLogHandler
        record - description of the log event. A null record is silently ignored and is not published
      • compareTo

        public int compareTo​(Handler o)
        Compares the handler with itself.
        Specified by:
        compareTo in interface Comparable<Handler>
        compareTo in class AbstractLogHandler
        o - the other handler
        less than 0, equal to 0, or greater than 0 if the handler is less, equal to, or greater than this one