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, e.g. logback, reload4j, log4j and JDK 1.4 logging. Other implementations such as NOPLogger and SimpleLogger are also supported.

LoggerFactory is essentially a wrapper around an ILoggerFactory instance provided by a SLF4JServiceProvider.

Please note that all methods in LoggerFactory are static.

Author:
Alexander Dorokhine, Robert Elliot, Ceki Gülcü
  • Field Details

    • PROVIDER_PROPERTY_KEY

      public static final String PROVIDER_PROPERTY_KEY
      System property for explicitly setting the provider class. If set and the provider could be instantiated, then the service loading mechanism will be bypassed.
      Since:
      2.0.9
      See Also:
  • Method Details

    • 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 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:
    • 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