Class Provider

  • Direct Known Subclasses:
    Log4jProvider, SimpleProvider

    @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.

    • Constructor Detail

      • Provider

        @Deprecated
        public Provider​(Properties props,
                        URL url,
                        ClassLoader classLoader)
        Deprecated.
        since 2.24.0
        Constructor used by the deprecated META-INF/log4j-provider.properties format.
        Since:
        2.0.1
      • Provider

        public Provider​(@Nullable Integer priority,
                        String versions)
        Parameters:
        priority - A positive number specifying the provider's priority or null if default,
        versions - Minimal API version required, should be set to CURRENT_VERSION.
        Since:
        2.24.0
    • Method Detail

      • getVersions

        public String getVersions()
        Returns the Log4j API versions supported by the implementation.
        Returns:
        A String containing the Log4j versions supported.
        Since:
        2.9.0
      • 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()
      • 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.
        Since:
        2.0.1
      • 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.
        Since:
        2.0.1
      • 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 a 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.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object