Package org.slf4j

Class LoggerFactory

java.lang.Object
org.slf4j.LoggerFactory

public final class LoggerFactory extends Object
The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for log4j, logback and JDK 1.4 logging. Other implementations such as NOPLogger and SimpleLogger are also supported.

LoggerFactory is essentially a wrapper around an ILoggerFactory instance bound with LoggerFactory at compile time.

Please note that all methods in LoggerFactory are static.

  • Field Details

  • Constructor Details

    • LoggerFactory

      private LoggerFactory()
  • Method Details

    • reset

      static void reset()
      Force LoggerFactory to consider itself uninitialized.

      This method is intended to be called by classes (in the same package) for testing purposes. This method is internal. It can be modified, renamed or removed at any time without notice.

      You are strongly discouraged from calling this method in production code.

    • performInitialization

      private static final void performInitialization()
    • messageContainsOrgSlf4jImplStaticLoggerBinder

      private static boolean messageContainsOrgSlf4jImplStaticLoggerBinder(String msg)
    • bind

      private static final void bind()
    • postBindCleanUp

      private static void postBindCleanUp()
    • fixSubstituteLoggers

      private static void fixSubstituteLoggers()
    • failedBinding

      static void failedBinding(Throwable t)
    • replayEvents

      private static void replayEvents()
    • emitReplayOrSubstituionWarning

      private static void emitReplayOrSubstituionWarning(SubstituteLoggingEvent event, int queueSize)
    • replaySingleEvent

      private static void replaySingleEvent(SubstituteLoggingEvent event)
    • emitSubstitutionWarning

      private static void emitSubstitutionWarning()
    • emitReplayWarning

      private static void emitReplayWarning(int eventCount)
    • versionSanityCheck

      private static final void versionSanityCheck()
    • findPossibleStaticLoggerBinderPathSet

      static Set<URL> findPossibleStaticLoggerBinderPathSet()
    • isAmbiguousStaticLoggerBinderPathSet

      private static boolean isAmbiguousStaticLoggerBinderPathSet(Set<URL> binderPathSet)
    • reportMultipleBindingAmbiguity

      private static void reportMultipleBindingAmbiguity(Set<URL> binderPathSet)
      Prints a warning message on the console if multiple bindings were found on the class path. No reporting is done otherwise.
    • isAndroid

      private static boolean isAndroid()
    • reportActualBinding

      private static void reportActualBinding(Set<URL> binderPathSet)
    • getLogger

      public static Logger getLogger(String name)
      Return a logger named according to the name parameter using the statically bound ILoggerFactory instance.
      Parameters:
      name - The name of the logger.
      Returns:
      logger
    • getLogger

      public static Logger getLogger(Class<?> clazz)
      Return a logger named corresponding to the class passed as parameter, using the statically bound ILoggerFactory instance.

      In case the the clazz parameter differs from the name of the caller as computed internally by SLF4J, a logger name mismatch warning will be printed but only if the slf4j.detectLoggerNameMismatch system property is set to true. By default, this property is not set and no warnings will be printed even in case of a logger name mismatch.

      Parameters:
      clazz - the returned logger will be named after clazz
      Returns:
      logger
      See Also:
    • nonMatchingClasses

      private static boolean nonMatchingClasses(Class<?> clazz, Class<?> autoComputedCallingClass)
    • getILoggerFactory

      public static ILoggerFactory getILoggerFactory()
      Return the ILoggerFactory instance in use.

      ILoggerFactory instance is bound with this class at compile time.

      Returns:
      the ILoggerFactory instance in use