Class Provider

java.lang.Object
org.apache.logging.log4j.spi.Provider

@NullMarked public class Provider extends Object
Service class used to bind the Log4j API with an implementation.

Implementors should register an implementation of this class with ServiceLoader.

Deprecated: the automatic registration of providers from META-INF/log4j-provider.properties is supported for compatibility reasons. Support for this file will be dropped in a future version.

  • Field Details

  • Constructor Details

  • Method Details

    • getVersions

      public String getVersions()
      Returns the Log4j API versions supported by the implementation.
      Returns:
      A String containing the Log4j versions supported.
    • getPriority

      public Integer getPriority()
      Gets the priority (natural ordering) of this Provider.

      Log4j selects the highest priority provider.

      Returns:
      the priority of this Provider
    • getClassName

      public @Nullable String getClassName()
      Gets the class name of the LoggerContextFactory implementation of this Provider.
      Returns:
      the class name of a LoggerContextFactory implementation or null if unspecified.
      See Also:
    • loadLoggerContextFactory

      public @Nullable Class<? extends LoggerContextFactory> loadLoggerContextFactory()
      Loads the LoggerContextFactory class specified by this Provider.
      Returns:
      the LoggerContextFactory implementation class or null if unspecified or a loader error occurred.
    • getLoggerContextFactory

      public LoggerContextFactory getLoggerContextFactory()
      Returns:
      The logger context factory to be used by LogManager.
      Since:
      2.24.0
    • getThreadContextMap

      public @Nullable String getThreadContextMap()
      Gets the class name of the ThreadContextMap implementation of this Provider.
      Returns:
      the class name of a ThreadContextMap implementation
    • loadThreadContextMap

      public @Nullable Class<? extends ThreadContextMap> loadThreadContextMap()
      Loads the ThreadContextMap class specified by this Provider.
      Returns:
      the ThreadContextMap implementation class or null if unspecified or a loading error occurred.
    • getThreadContextMapInstance

      public ThreadContextMap getThreadContextMapInstance()
      Returns:
      The thread context map to be used by ThreadContext.
      Since:
      2.24.0
    • getUrl

      @Deprecated public @Nullable URL getUrl()
      Deprecated.
      since 2.24.0, without replacement.
      Gets the URL containing this Provider's Log4j details.
      Returns:
      the URL corresponding to the Provider META-INF/log4j-provider.properties file or null for a provider class.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object