Class LogFactory

java.lang.Object
com.guicedee.logger.LogFactory

public class LogFactory
extends java.lang.Object
Default handler for java.util.logging framework.
Since:
13 Dec 2016
Author:
GedMarc
  • Method Summary

    Modifier and Type Method Description
    static ConsoleSTDOutputHandler configureConsoleColourOutput​(java.util.logging.Level outputLevel)  
    static ConsoleSTDOutputHandler configureConsoleSingleLineOutput​(java.util.logging.Level outputLevel)
    Configures all the JWebMP Loggers to log to console with the given output using the SingleLineFormatter
    static ConsoleSTDOutputHandler configureConsoleSingleLineOutput​(java.util.logging.Level outputLevel, boolean inverted)
    Configures all the JWebMP Loggers to log to console with the given output using the SingleLineFormatter
    static void configureDefaultLogHiding()
    Sets some of the configurations to a not so floody log
    ConsoleSTDOutputHandler getConsoleLogger()
    Returns the console logger
    static java.util.logging.Level getDefaultLevel()
    Returns the currently assigned default level
    static LogFactory getInstance()
    Returns an instance of the log factory
    static java.util.logging.Logger getLog​(java.lang.Class name)
    Alias for get logger
    static java.util.logging.Logger getLog​(java.lang.String name)
    Alias for get logger
    java.util.logging.Logger getLogger​(java.lang.String name)
    Returns a logger in Async that may or may not log to the console according to configuration
    static boolean isLogToConsole()
    If we should ever log to console
    static void setDefaultLevel​(java.util.logging.Level level)
    Sets the default level on all the loggers currently associated, as well as any future loggers
    static void setGroupLevel​(java.lang.String category, java.util.logging.Level newLevel)
    Sets the default level on all the loggers currently associated, as well as any future loggers
    static void setLogToConsole​(boolean LogToConsole)
    If we should ever log to console

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • configureConsoleColourOutput

      public static ConsoleSTDOutputHandler configureConsoleColourOutput​(java.util.logging.Level outputLevel)
    • configureConsoleSingleLineOutput

      public static ConsoleSTDOutputHandler configureConsoleSingleLineOutput​(java.util.logging.Level outputLevel)
      Configures all the JWebMP Loggers to log to console with the given output using the SingleLineFormatter
      Parameters:
      outputLevel - The level to apply
      Returns:
      The Handler that was added
    • configureConsoleSingleLineOutput

      public static ConsoleSTDOutputHandler configureConsoleSingleLineOutput​(java.util.logging.Level outputLevel, boolean inverted)
      Configures all the JWebMP Loggers to log to console with the given output using the SingleLineFormatter
      Parameters:
      outputLevel - The level to apply
      Returns:
      The Handler that was added
    • configureDefaultLogHiding

      public static void configureDefaultLogHiding()
      Sets some of the configurations to a not so floody log

      LogFactory.setGroupLevel("org.hibernate", Level.INFO); LogFactory.setGroupLevel("io.undertow.request", Level.INFO); LogFactory.setGroupLevel("jakarta.faces.component", Level.INFO); LogFactory.setGroupLevel("com.google.inject", Level.CONFIG); LogFactory.setGroupLevel("org.xnio", Level.INFO); LogFactory.setGroupLevel("btm", Level.INFO); LogFactory.setGroupLevel("com.microsoft.sqlserver.jdbc", Level.INFO); LogFactory.setGroupLevel("com.hazelcast", Level.INFO); LogFactory.setGroupLevel("jakarta.net", Level.INFO); LogFactory.setGroupLevel("org.apache.cxf", Level.CONFIG); LogFactory.setGroupLevel("jdk.event.security", Level.INFO); LogFactory.setGroupLevel("jakarta.xml.bind", Level.CONFIG); LogFactory.setGroupLevel("jakarta.enterprise.resource.webcontainer.jsf", Level.INFO);

    • getLog

      public static java.util.logging.Logger getLog​(java.lang.String name)
      Alias for get logger
      Parameters:
      name - Logger name to return
      Returns:
      A JDK 8 Logger
    • getLogger

      public java.util.logging.Logger getLogger​(java.lang.String name)
      Returns a logger in Async that may or may not log to the console according to configuration
      Parameters:
      name - Returns the logger
      Returns:
      The newly created logger
    • getInstance

      public static LogFactory getInstance()
      Returns an instance of the log factory
      Returns:
      The static instance
    • getDefaultLevel

      public static java.util.logging.Level getDefaultLevel()
      Returns the currently assigned default level
      Returns:
      The default level assigned to the
    • setGroupLevel

      public static void setGroupLevel​(java.lang.String category, java.util.logging.Level newLevel)
      Sets the default level on all the loggers currently associated, as well as any future loggers
      Parameters:
      newLevel - The default level to apply on all loggers on all registered handlers
    • setDefaultLevel

      public static void setDefaultLevel​(java.util.logging.Level level)
      Sets the default level on all the loggers currently associated, as well as any future loggers
      Parameters:
      level - The default level to apply on all loggers on all registered handlers
    • getLog

      public static java.util.logging.Logger getLog​(java.lang.Class name)
      Alias for get logger
      Parameters:
      name - Logger name to return
      Returns:
      A JDK 8 Logger
    • isLogToConsole

      public static boolean isLogToConsole()
      If we should ever log to console
      Returns:
      If logging to console is enabled
    • setLogToConsole

      public static void setLogToConsole​(boolean LogToConsole)
      If we should ever log to console
      Parameters:
      LogToConsole - If must log to console
    • getConsoleLogger

      public ConsoleSTDOutputHandler getConsoleLogger()
      Returns the console logger
      Returns:
      The console logger instance