Class ConfigurationFactory

    • Field Detail

      • CONFIGURATION_FACTORY_PROPERTY

        public static final java.lang.String CONFIGURATION_FACTORY_PROPERTY
        Allows the ConfigurationFactory class to be specified as a system property.
        See Also:
        Constant Field Values
      • CONFIGURATION_FILE_PROPERTY

        public static final java.lang.String CONFIGURATION_FILE_PROPERTY
        Allows the location of the configuration file to be specified as a system property.
        See Also:
        Constant Field Values
      • LOG4J1_CONFIGURATION_FILE_PROPERTY

        public static final java.lang.String LOG4J1_CONFIGURATION_FILE_PROPERTY
        See Also:
        Constant Field Values
      • LOG4J1_EXPERIMENTAL

        public static final java.lang.String LOG4J1_EXPERIMENTAL
        See Also:
        Constant Field Values
      • AUTHORIZATION_PROVIDER

        public static final java.lang.String AUTHORIZATION_PROVIDER
        See Also:
        Constant Field Values
      • CATEGORY

        public static final java.lang.String CATEGORY
        Plugin category used to inject a ConfigurationFactory Plugin class.
        Since:
        2.1
        See Also:
        Constant Field Values
      • LOGGER

        protected static final Logger LOGGER
        Allows subclasses access to the status logger without creating another instance.
      • TEST_PREFIX

        protected static final java.lang.String TEST_PREFIX
        File name prefix for test configurations.
        See Also:
        Constant Field Values
      • DEFAULT_PREFIX

        protected static final java.lang.String DEFAULT_PREFIX
        File name prefix for standard configurations.
        See Also:
        Constant Field Values
      • CLASS_LOADER_SCHEME

        private static final java.lang.String CLASS_LOADER_SCHEME
        The name of the classloader URI scheme.
        See Also:
        Constant Field Values
      • CLASS_PATH_SCHEME

        private static final java.lang.String CLASS_PATH_SCHEME
        The name of the classpath URI scheme, synonymous with the classloader URI scheme.
        See Also:
        Constant Field Values
      • LOCK

        private static final java.util.concurrent.locks.Lock LOCK
      • PREFIXES

        private static final java.lang.String[] PREFIXES
    • Constructor Detail

      • ConfigurationFactory

        public ConfigurationFactory()
    • Method Detail

      • getInstance

        public static ConfigurationFactory getInstance()
        Returns the ConfigurationFactory.
        Returns:
        the ConfigurationFactory.
      • addFactory

        private static void addFactory​(java.util.Collection<ConfigurationFactory> list,
                                       java.lang.String factoryClass)
      • setConfigurationFactory

        public static void setConfigurationFactory​(ConfigurationFactory factory)
        Sets the configuration factory. This method is not intended for general use and may not be thread safe.
        Parameters:
        factory - the ConfigurationFactory.
      • resetConfigurationFactory

        public static void resetConfigurationFactory()
        Resets the ConfigurationFactory to the default. This method is not intended for general use and may not be thread safe.
      • removeConfigurationFactory

        public static void removeConfigurationFactory​(ConfigurationFactory factory)
        Removes the ConfigurationFactory. This method is not intended for general use and may not be thread safe.
        Parameters:
        factory - The factory to remove.
      • getSupportedTypes

        protected abstract java.lang.String[] getSupportedTypes()
      • getTestPrefix

        protected java.lang.String getTestPrefix()
      • getDefaultPrefix

        protected java.lang.String getDefaultPrefix()
      • getVersion

        protected java.lang.String getVersion()
      • isActive

        protected boolean isActive()
      • getConfiguration

        public Configuration getConfiguration​(LoggerContext loggerContext,
                                              java.lang.String name,
                                              java.net.URI configLocation)
        Returns the Configuration.
        Parameters:
        loggerContext - The logger context
        name - The configuration name.
        configLocation - The configuration location.
        Returns:
        The Configuration.
      • getConfiguration

        public Configuration getConfiguration​(LoggerContext loggerContext,
                                              java.lang.String name,
                                              java.net.URI configLocation,
                                              java.lang.ClassLoader loader)
        Returns the Configuration obtained using a given ClassLoader.
        Parameters:
        loggerContext - The logger context
        name - The configuration name.
        configLocation - A URI representing the location of the configuration.
        loader - The default ClassLoader to use. If this is null, then the default ClassLoader will be used.
        Returns:
        The Configuration.
      • getConfiguration

        public Configuration getConfiguration​(LoggerContext loggerContext,
                                              java.lang.String name,
                                              java.util.List<java.net.URI> configLocations)
        {@return a {@link Configuration} created using provided configuration location {@link URI}s}

        Configurations will be loaded and merged in the given order using the effective merge strategy. The default can be changed using the "log4j.mergeStrategy" system property.

        If the provided list of URIs is empty, the configuration factory attempts to load an implementation-dependent set of default locations. If no configuration can be found, a ConfigurationException is thrown.

        Parameters:
        loggerContext - a logger context, may be null
        name - a configuration name, may be null
        configLocations - configuration location URIs, may not contain or be null
        Throws:
        ConfigurationException - if configuration could not be created
        java.lang.NullPointerException - if configLocations contains or is null
        Since:
        2.26.0
      • isClassLoaderUri

        static boolean isClassLoaderUri​(java.net.URI uri)
      • extractClassLoaderUriPath

        static java.lang.String extractClassLoaderUriPath​(java.net.URI uri)
      • getInputFromString

        @Deprecated
        protected ConfigurationSource getInputFromString​(java.lang.String config,
                                                         java.lang.ClassLoader loader)
        Deprecated.
        Loads the configuration from the location represented by the String.
        Parameters:
        config - The configuration location.
        loader - The default ClassLoader to use.
        Returns:
        The InputSource to use to read the configuration.