Class ProviderUtil


  • public final class ProviderUtil
    extends java.lang.Object
    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

      Fields 
      Modifier and Type Field Description
      protected static java.lang.String PROVIDER_RESOURCE
      Resource name for a Log4j 2 provider properties file.
      protected static java.util.Collection<Provider> PROVIDERS
      Loaded providers.
      protected static java.util.concurrent.locks.Lock STARTUP_LOCK
      Guards the ProviderUtil singleton instance from lazy initialization.
    • Field Detail

      • PROVIDER_RESOURCE

        protected static final java.lang.String PROVIDER_RESOURCE
        Resource name for a Log4j 2 provider properties file.
        See Also:
        Constant Field Values
      • PROVIDERS

        protected static final java.util.Collection<Provider> PROVIDERS
        Loaded providers.
      • STARTUP_LOCK

        protected static final java.util.concurrent.locks.Lock STARTUP_LOCK
        Guards the ProviderUtil singleton instance from lazy initialization. This is primarily used for OSGi support.
        Since:
        2.1
    • Method Detail

      • addProvider

        protected static void addProvider​(Provider provider)
      • loadProvider

        protected static void loadProvider​(java.net.URL url,
                                           java.lang.ClassLoader cl)
        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 file
        cl - the ClassLoader to load the provider classes with
      • loadProviders

        protected static void loadProviders​(java.lang.ClassLoader classLoader)
        Parameters:
        classLoader - null can be used to mark the bootstrap class loader.
      • loadProviders

        @Deprecated
        protected static void loadProviders​(java.util.Enumeration<java.net.URL> urls,
                                            java.lang.ClassLoader cl)
        Deprecated.
        Use loadProvider(java.net.URL, ClassLoader) instead. Will be removed in 3.0.
      • getProviders

        public static java.lang.Iterable<Provider> getProviders()
      • hasProviders

        public static boolean hasProviders()
      • lazyInit

        protected static void lazyInit()
        Lazily initializes the ProviderUtil singleton.
        Since:
        2.1
      • findClassLoader

        public static java.lang.ClassLoader findClassLoader()