Package org.apache.logging.log4j.spi
Class Provider
- java.lang.Object
-
- org.apache.logging.log4j.spi.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.propertiesis supported for compatibility reasons. Support for this file will be dropped in a future version.
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringCURRENT_VERSIONConstant inlined by the compilerstatic StringFACTORY_PRIORITYDeprecated.since 2.24.0static StringLOGGER_CONTEXT_FACTORYDeprecated.since 2.24.0static StringPROVIDER_PROPERTY_NAMESystem property used to specify the class name of the provider to use.static StringTHREAD_CONTEXT_MAPDeprecated.since 2.24.0
-
Constructor Summary
Constructors Constructor Description Provider(@Nullable Integer priority, String versions)Provider(@Nullable Integer priority, String versions, @Nullable Class<? extends LoggerContextFactory> loggerContextFactoryClass)Provider(@Nullable Integer priority, String versions, @Nullable Class<? extends LoggerContextFactory> loggerContextFactoryClass, @Nullable Class<? extends ThreadContextMap> threadContextMapClass)Provider(Properties props, URL url, ClassLoader classLoader)Deprecated.since 2.24.0
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(Object o)@Nullable StringgetClassName()Gets the class name of theLoggerContextFactoryimplementation of this Provider.LoggerContextFactorygetLoggerContextFactory()IntegergetPriority()Gets the priority (natural ordering) of this Provider.@Nullable StringgetThreadContextMap()Gets the class name of theThreadContextMapimplementation of this Provider.ThreadContextMapgetThreadContextMapInstance()@Nullable URLgetUrl()Deprecated.since 2.24.0, without a replacement.StringgetVersions()Returns the Log4j API versions supported by the implementation.inthashCode()@Nullable Class<? extends LoggerContextFactory>loadLoggerContextFactory()Loads theLoggerContextFactoryclass specified by this Provider.@Nullable Class<? extends ThreadContextMap>loadThreadContextMap()Loads theThreadContextMapclass specified by this Provider.StringtoString()
-
-
-
Field Detail
-
CURRENT_VERSION
protected static final String CURRENT_VERSION
Constant inlined by the compiler- Since:
- 2.24.0
- See Also:
- Constant Field Values
-
FACTORY_PRIORITY
@Deprecated public static final String FACTORY_PRIORITY
Deprecated.since 2.24.0Property name to set for a Log4j 2 provider to specify the priority of this implementation.- Since:
- 2.0.1
- See Also:
- Constant Field Values
-
THREAD_CONTEXT_MAP
@Deprecated public static final String THREAD_CONTEXT_MAP
Deprecated.since 2.24.0Property name to set to the implementation ofThreadContextMap.- Since:
- 2.0.1
- See Also:
- Constant Field Values
-
LOGGER_CONTEXT_FACTORY
@Deprecated public static final String LOGGER_CONTEXT_FACTORY
Deprecated.since 2.24.0Property name to set to the implementation ofLoggerContextFactory.- Since:
- 2.0.1
- See Also:
- Constant Field Values
-
PROVIDER_PROPERTY_NAME
public static final String PROVIDER_PROPERTY_NAME
System property used to specify the class name of the provider to use.- Since:
- 2.24.0
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Provider
@Deprecated public Provider(Properties props, URL url, ClassLoader classLoader)
Deprecated.since 2.24.0Constructor used by the deprecatedMETA-INF/log4j-provider.propertiesformat.- Since:
- 2.0.1
-
Provider
public Provider(@Nullable Integer priority, String versions)
- Parameters:
priority- A positive number specifying the provider's priority ornullif default,versions- Minimal API version required, should be set toCURRENT_VERSION.- Since:
- 2.24.0
-
Provider
public Provider(@Nullable Integer priority, String versions, @Nullable Class<? extends LoggerContextFactory> loggerContextFactoryClass)
- Parameters:
priority- A positive number specifying the provider's priority ornullif default,versions- Minimal API version required, should be set toCURRENT_VERSION,loggerContextFactoryClass- A public exported implementation ofLoggerContextFactoryornullifgetLoggerContextFactory()is also implemented.- Since:
- 2.9.0
-
Provider
public Provider(@Nullable Integer priority, String versions, @Nullable Class<? extends LoggerContextFactory> loggerContextFactoryClass, @Nullable Class<? extends ThreadContextMap> threadContextMapClass)
- Parameters:
priority- A positive number specifying the provider's priority ornullif default,versions- Minimal API version required, should be set toCURRENT_VERSION,loggerContextFactoryClass- A public exported implementation ofLoggerContextFactoryornullifgetLoggerContextFactory()is also implemented,threadContextMapClass- A public exported implementation ofThreadContextMapornullifgetThreadContextMapInstance()is implemented.- Since:
- 2.9.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 theLoggerContextFactoryimplementation of this Provider.- Returns:
- the class name of a LoggerContextFactory implementation or
nullif unspecified. - See Also:
loadLoggerContextFactory()
-
loadLoggerContextFactory
public @Nullable Class<? extends LoggerContextFactory> loadLoggerContextFactory()
Loads theLoggerContextFactoryclass specified by this Provider.- Returns:
- the LoggerContextFactory implementation class or
nullif 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 theThreadContextMapimplementation of this Provider.- Returns:
- the class name of a ThreadContextMap implementation
-
loadThreadContextMap
public @Nullable Class<? extends ThreadContextMap> loadThreadContextMap()
Loads theThreadContextMapclass specified by this Provider.- Returns:
- the
ThreadContextMapimplementation class ornullif 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.propertiesfile ornullfor a provider class.
-
-