Class LoggerFactory


  • public final 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 java.util.logging.Handler addAnsiConsoleHandler()
      Create a new ANSI console handler with the default log messages level and add it to the bottom logger.
      static java.util.logging.Handler addAnsiConsoleHandler​(java.util.logging.Level level)
      Create a new ANSI console handler with a given log messages level and add it to the bottom logger.
      static java.util.logging.Handler addFileHandler​(java.lang.String fileNamePattern)
      Create a new file handler with the default log messages level and add it to the bottom logger.
      static @Nullable java.util.logging.Handler addFileHandler​(java.lang.String fileNamePattern, java.util.logging.Level level)
      Create a new file handler with a given log messages level and add it to the bottom logger.
      static java.util.logging.Handler addHandler​(java.util.logging.Handler handler, java.util.logging.Level level)
      Add a given log handler to the current bottom logger and set a given log messages level to the handler.
      static java.util.logging.Logger appendLogger​(java.lang.String loggerName)
      Create a new logger with a given name and ALL log messages level and append it to the logger hierarchy as the new bottom logger.
      static void demoLog​(@NotNull java.util.logging.Logger logger)  
      static java.lang.String dumpObjectToString​(java.lang.Object object)
      Recursively dump object's attributes to a string.
      static java.util.logging.Logger getLogger()
      Get the getLogger.
      static boolean init​(java.lang.String loggerName)
      Create a new top logger with a given name and ALL log messages level.
      static java.util.logging.Level loggingLevelForVerbosity​(int verbosity)
      Translate a given numerical verbosity level into the log level.
      static void main​(java.lang.String[] args)  
      static @NotNull java.lang.String tempLogFilePatternForName​(java.lang.String baseName)
      Get the temp log file pattern for a given base name.
      • Methods inherited from class java.lang.Object

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

      • DEFAULT_CONSOLE_LOG_LEVEL

        public static final java.util.logging.Level DEFAULT_CONSOLE_LOG_LEVEL
      • DEFAULT_FILE_LOG_LEVEL

        public static final java.util.logging.Level DEFAULT_FILE_LOG_LEVEL
      • TEMP_LOG_FILE_PATTERN

        public static final java.lang.String TEMP_LOG_FILE_PATTERN
        See Also:
        Constant Field Values
      • TOP_LOGGER

        public static final java.util.logging.Logger TOP_LOGGER
      • HANDLER_ENCODING

        public static final java.lang.String HANDLER_ENCODING
        See Also:
        Constant Field Values
      • TEMP_LOG_FILE_DATE_FORMAT

        public static final java.text.DateFormat TEMP_LOG_FILE_DATE_FORMAT
    • Constructor Detail

      • LoggerFactory

        public LoggerFactory()
    • Method Detail

      • init

        public static boolean init​(java.lang.String loggerName)
        Create a new top logger with a given name and ALL log messages level.
        Parameters:
        loggerName - a name of the new logger (the last part of the logger hierarchy)
        Returns:
        true if the logger has been created, false the logger cloud not be created as there is already a top logger
      • appendLogger

        public static java.util.logging.Logger appendLogger​(java.lang.String loggerName)
        Create a new logger with a given name and ALL log messages level and append it to the logger hierarchy as the new bottom logger.
        Parameters:
        loggerName - a name of the new logger (the last part of the logger hierarchy)
        Returns:
        the new logger
      • getLogger

        @Contract(pure=true)
        public static java.util.logging.Logger getLogger()
        Get the getLogger.
        Returns:
        the getLogger
      • addHandler

        @Contract("_, _ -> param1")
        public static java.util.logging.Handler addHandler​(java.util.logging.Handler handler,
                                                           java.util.logging.Level level)
        Add a given log handler to the current bottom logger and set a given log messages level to the handler.
        Parameters:
        handler - the handler to add
        level - the log message level to set to the handler
        Returns:
        the added handler
      • addAnsiConsoleHandler

        public static java.util.logging.Handler addAnsiConsoleHandler()
        Create a new ANSI console handler with the default log messages level and add it to the bottom logger.
        Returns:
        the new handler
      • addAnsiConsoleHandler

        public static java.util.logging.Handler addAnsiConsoleHandler​(java.util.logging.Level level)
        Create a new ANSI console handler with a given log messages level and add it to the bottom logger.
        Parameters:
        level - the level of log messages for the handler
        Returns:
        the new handler
      • addFileHandler

        public static java.util.logging.Handler addFileHandler​(java.lang.String fileNamePattern)
        Create a new file handler with the default log messages level and add it to the bottom logger.
        Parameters:
        fileNamePattern - the name pattern of the output file
        Returns:
        the new handler or null if the handler could not be added
      • addFileHandler

        @Nullable
        public static @Nullable java.util.logging.Handler addFileHandler​(java.lang.String fileNamePattern,
                                                                         java.util.logging.Level level)
        Create a new file handler with a given log messages level and add it to the bottom logger.
        Parameters:
        fileNamePattern - the name pattern of the output file
        level - the level of log messages for the handler
        Returns:
        the new handler
      • loggingLevelForVerbosity

        @Contract(pure=true)
        public static java.util.logging.Level loggingLevelForVerbosity​(int verbosity)
        Translate a given numerical verbosity level into the log level.
        Parameters:
        verbosity - the verbosity level number
        Returns:
        the corresponding log level
      • tempLogFilePatternForName

        @NotNull
        @Contract(pure=true)
        public static @NotNull java.lang.String tempLogFilePatternForName​(java.lang.String baseName)
        Get the temp log file pattern for a given base name.
        Parameters:
        baseName - the base name
        Returns:
        the resulting temp log file pattern
      • dumpObjectToString

        public static java.lang.String dumpObjectToString​(java.lang.Object object)
        Recursively dump object's attributes to a string.
        Parameters:
        object - the object to dump
        Returns:
        the resulting string dump
      • demoLog

        public static void demoLog​(@NotNull
                                   @NotNull java.util.logging.Logger logger)
      • main

        public static void main​(java.lang.String[] args)
                         throws java.io.IOException
        Throws:
        java.io.IOException