Class LoggerFactory

java.lang.Object
com.chrisnewland.freelogj.LoggerFactory

public class LoggerFactory extends Object
  • Field Details

  • Constructor Details

    • LoggerFactory

      public LoggerFactory()
  • Method Details

    • 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, 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, PrintStream printStream, 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(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(Class<?> clazz)
      Returns a Logger for the given Class. The fully qualified class name is printed on each log line.
      Parameters:
      clazz - The class