Class ProviderUtil
java.lang.Object
org.apache.logging.log4j.util.ProviderUtil
Consider this class private.
Utility class for Log4j Providers. When integrating with an application container framework, any Log4j
Providers not accessible through standard classpath scanning should
loadProvider(java.net.URL, ClassLoader) a classpath accordingly.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String[]private static final Loggerprivate static Provider(package private) static final StringResource name for a Log4j 2 provider properties file.(package private) static final Collection<Provider> Loaded providers.(package private) static final LockGuards the ProviderUtil singleton instance from lazy initialization. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static voidaddProvider(Provider provider) static ClassLoaderstatic Providerstatic boolean(package private) static voidlazyInit()Lazily initializes the ProviderUtil singleton.(package private) static voidloadProvider(URL url, ClassLoader cl) Loads an individual Provider implementation.(package private) static voidloadProviders(Enumeration<URL> urls, ClassLoader cl) Deprecated.(package private) static ProviderselectProvider(PropertiesUtil properties, Collection<Provider> providers, Logger statusLogger) Used to test the publicgetProvider()method.private static booleanvalidVersion(String version)
-
Field Details
-
PROVIDER_RESOURCE
Resource name for a Log4j 2 provider properties file.- See Also:
-
PROVIDERS
Loaded providers. -
STARTUP_LOCK
Guards the ProviderUtil singleton instance from lazy initialization.This is primarily used for OSGi support. It allows the OSGi Activator to pause the startup and wait for a Provider to be installed. See LOG4J2-373.
-
COMPATIBLE_API_VERSIONS
-
LOGGER
-
PROVIDER
-
-
Constructor Details
-
ProviderUtil
private ProviderUtil()
-
-
Method Details
-
addProvider
-
loadProvider
Loads an individual Provider implementation. This method is really only useful for the OSGi bundle activator and this class itself.- Parameters:
url- the URL to the provider properties filecl- the ClassLoader to load the provider classes with
-
loadProviders
Deprecated.UseloadProvider(java.net.URL, ClassLoader)instead. Will be removed in 3.0. -
getProvider
- Since:
- 2.24.0
-
getProviders
-
hasProviders
public static boolean hasProviders() -
lazyInit
static void lazyInit()Lazily initializes the ProviderUtil singleton.Note that the following initial call to ProviderUtil may block until a Provider has been installed when running in an OSGi environment.
-
selectProvider
static Provider selectProvider(PropertiesUtil properties, Collection<Provider> providers, Logger statusLogger) Used to test the publicgetProvider()method. -
findClassLoader
-
validVersion
-
loadProvider(java.net.URL, ClassLoader)instead.