Class LoggerFactory


  • public class LoggerFactory
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      LoggerFactory()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Logger getLogger​(java.lang.Class<?> clazz)
      Returns a Logger for the given Class.
      static void initialise​(Logger.LogLevel logLevel)
      Initialise the LoggerFactory with the given Logger.LogLevel.
      static void initialise​(Logger.LogLevel logLevel, java.io.PrintStream printStream)
      Initialise the LoggerFactory with the given Logger.LogLevel and PrintStream.
      static void initialise​(Logger.LogLevel logLevel, java.io.PrintStream printStream, java.time.format.DateTimeFormatter dateTimeFormatter)
      Initialise the LoggerFactory with the given Logger.LogLevel, PrintStream, and DateTimeFormatter All loggers created by getLogger will be set at this LogLevel and use this PrintStream and DateTimeFormatter.
      static void setLogFile​(java.nio.file.Path logFilePath)
      Set the LoggerFactory PrintStream to use a PrintStream wrapping a FileOutputStream opened on the given Path All loggers created by getLogger will use this PrintStream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • printStream

        private static java.io.PrintStream printStream
      • dateFormat

        private static java.time.format.DateTimeFormatter dateFormat
    • Constructor Detail

      • LoggerFactory

        public LoggerFactory()
    • Method Detail

      • initialise

        public static void initialise​(Logger.LogLevel logLevel)
        Initialise the LoggerFactory with the given Logger.LogLevel. All loggers created by getLogger will be set at this LogLevel.
        Parameters:
        logLevel - The logging level. Messages below this level will not be logged.
      • initialise

        public static void initialise​(Logger.LogLevel logLevel,
                                      java.io.PrintStream printStream)
        Initialise the LoggerFactory with the given Logger.LogLevel and PrintStream. All loggers created by getLogger will be set at this LogLevel and use this PrintStream.
        Parameters:
        logLevel - Messages below this level will not be logged.
        printStream - Messages will be written to this PrintStream.
      • initialise

        public static void initialise​(Logger.LogLevel logLevel,
                                      java.io.PrintStream printStream,
                                      java.time.format.DateTimeFormatter dateTimeFormatter)
        Initialise the LoggerFactory with the given Logger.LogLevel, PrintStream, and DateTimeFormatter All loggers created by getLogger will be set at this LogLevel and use this PrintStream and DateTimeFormatter.
        Parameters:
        logLevel - Messages below this level will not be logged.
        printStream - Messages will be written to this PrintStream.
        dateTimeFormatter - Messages timestamps will be formatted with this DateTimeFormatter.
      • setLogFile

        public static void setLogFile​(java.nio.file.Path logFilePath)
        Set the LoggerFactory PrintStream to use a PrintStream wrapping a FileOutputStream opened on the given Path All loggers created by getLogger will use this PrintStream.
        Parameters:
        logFilePath - Path to the log file. If the log file cannot be opened, a RuntimeException is thrown wrapping the FileNotFoundException.
      • getLogger

        public static Logger getLogger​(java.lang.Class<?> clazz)
        Returns a Logger for the given Class. The fully qualified class name is printed on each log line.
        Parameters:
        clazz - The class