Package org.apache.logging.log4j.spi
Class Provider
- java.lang.Object
-
- org.apache.logging.log4j.spi.Provider
-
- Direct Known Subclasses:
JULProvider,Log4jProvider,SimpleProvider,SLF4JProvider
@NullMarked public class Provider extends java.lang.ObjectService 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 private java.lang.ref.WeakReference<java.lang.ClassLoader>classLoaderDeprecated.private @Nullable java.lang.StringclassNameDeprecated.protected static java.lang.StringCURRENT_VERSIONConstant inlined by the compilerprivate static intDEFAULT_PRIORITYprivate static java.lang.StringDISABLE_CONTEXT_MAPprivate static java.lang.StringDISABLE_THREAD_CONTEXTstatic java.lang.StringFACTORY_PRIORITYDeprecated.since 2.24.0private static LoggerLOGGERstatic java.lang.StringLOGGER_CONTEXT_FACTORYDeprecated.since 2.24.0private @Nullable java.lang.Class<? extends LoggerContextFactory>loggerContextFactoryClassprivate intprioritystatic java.lang.StringPROVIDER_PROPERTY_NAMESystem property used to specify the class name of the provider to use.static java.lang.StringTHREAD_CONTEXT_MAPDeprecated.since 2.24.0private @Nullable java.lang.StringthreadContextMapDeprecated.private @Nullable java.lang.Class<? extends ThreadContextMap>threadContextMapClassprivate @Nullable java.net.URLurlDeprecated.private @Nullable java.lang.Stringversions
-
Constructor Summary
Constructors Constructor Description Provider(@Nullable java.lang.Integer priority, java.lang.String versions)Provider(@Nullable java.lang.Integer priority, java.lang.String versions, @Nullable java.lang.Class<? extends LoggerContextFactory> loggerContextFactoryClass)Provider(@Nullable java.lang.Integer priority, java.lang.String versions, @Nullable java.lang.Class<? extends LoggerContextFactory> loggerContextFactoryClass, @Nullable java.lang.Class<? extends ThreadContextMap> threadContextMapClass)Provider(java.util.Properties props, java.net.URL url, java.lang.ClassLoader classLoader)Deprecated.since 2.24.0
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(java.lang.Object o)@Nullable java.lang.StringgetClassName()Gets the class name of theLoggerContextFactoryimplementation of this Provider.LoggerContextFactorygetLoggerContextFactory()java.lang.IntegergetPriority()Gets the priority (natural ordering) of this Provider.@Nullable java.lang.StringgetThreadContextMap()Gets the class name of theThreadContextMapimplementation of this Provider.ThreadContextMapgetThreadContextMapInstance()@Nullable java.net.URLgetUrl()Deprecated.since 2.24.0, without a replacement.java.lang.StringgetVersions()Returns the Log4j API versions supported by the implementation.inthashCode()@Nullable java.lang.Class<? extends LoggerContextFactory>loadLoggerContextFactory()Loads theLoggerContextFactoryclass specified by this Provider.@Nullable java.lang.Class<? extends ThreadContextMap>loadThreadContextMap()Loads theThreadContextMapclass specified by this Provider.java.lang.StringtoString()
-
-
-
Field Detail
-
CURRENT_VERSION
protected static final java.lang.String CURRENT_VERSION
Constant inlined by the compiler- Since:
- 2.24.0
- See Also:
- Constant Field Values
-
FACTORY_PRIORITY
@Deprecated public static final java.lang.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 java.lang.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 java.lang.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 java.lang.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
-
DISABLE_CONTEXT_MAP
private static final java.lang.String DISABLE_CONTEXT_MAP
- See Also:
- Constant Field Values
-
DISABLE_THREAD_CONTEXT
private static final java.lang.String DISABLE_THREAD_CONTEXT
- See Also:
- Constant Field Values
-
DEFAULT_PRIORITY
private static final int DEFAULT_PRIORITY
- See Also:
- Constant Field Values
-
LOGGER
private static final Logger LOGGER
-
priority
private final int priority
-
className
@Deprecated private final @Nullable java.lang.String className
Deprecated.
-
loggerContextFactoryClass
private final @Nullable java.lang.Class<? extends LoggerContextFactory> loggerContextFactoryClass
-
threadContextMap
@Deprecated private final @Nullable java.lang.String threadContextMap
Deprecated.
-
threadContextMapClass
private final @Nullable java.lang.Class<? extends ThreadContextMap> threadContextMapClass
-
versions
private final @Nullable java.lang.String versions
-
url
@Deprecated private final @Nullable java.net.URL url
Deprecated.
-
classLoader
@Deprecated private final java.lang.ref.WeakReference<java.lang.ClassLoader> classLoader
Deprecated.
-
-
Constructor Detail
-
Provider
@Deprecated public Provider(java.util.Properties props, java.net.URL url, java.lang.ClassLoader classLoader)Deprecated.since 2.24.0Constructor used by the deprecatedMETA-INF/log4j-provider.propertiesformat.- Since:
- 2.0.1
-
Provider
public Provider(@Nullable java.lang.Integer priority, java.lang.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 java.lang.Integer priority, java.lang.String versions, @Nullable java.lang.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 java.lang.Integer priority, java.lang.String versions, @Nullable java.lang.Class<? extends LoggerContextFactory> loggerContextFactoryClass, @Nullable java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.String getThreadContextMap()
Gets the class name of theThreadContextMapimplementation of this Provider.- Returns:
- the class name of a ThreadContextMap implementation
-
loadThreadContextMap
public @Nullable java.lang.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 java.net.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.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-