Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.logging.log4j.core.config
Class ConfigurationFactory

    java.lang.Object
      org.apache.logging.log4j.core.config.ConfigurationFactory

Direct Known Subclasses:
  JsonConfigurationFactory, XmlConfigurationFactory, YamlConfigurationFactory

    public abstract class ConfigurationFactory

extends Object

Factory class for parsed `Configuration` objects from a configuration file. ConfigurationFactory allows the configuration implementation to be dynamically chosen in 1 of 3 ways:

1. A system property named "log4j.configurationFactory" can be set with the name of the ConfigurationFactory to be used.
2. setConfigurationFactory(ConfigurationFactory) can be called with the instance of the ConfigurationFactory to be used. This must be called before any other calls to Log4j.
3. A ConfigurationFactory implementation can be added to the classpath and configured as a plugin in the `ConfigurationFactory` category. The `Order` annotation should be used to configure the factory to be the first one inspected. See XmlConfigurationFactory for an example.

If the ConfigurationFactory that was added returns null on a call to getConfiguration the any other ConfigurationFactories found as plugins will be called in their respective order. DefaultConfiguration is always called last if no configuration has been returned.

Field Summary
`static String` | `CATEGORY` Plugin category used to inject a ConfigurationFactory `Plugin` class.
`static String` | `CONFIGURATION_FACTORY_PROPERTY` Allow the ConfigurationFactory class to be specified as a system property.
`static String` | `CONFIGURATION_FILE_PROPERTY` Allow the location of the configuration file to be specified as a system property.
`protected static String` | `DEFAULT_PREFIX` File name prefix for standard configurations.
`protected static org.apache.logging.log4j.Logger` | `LOGGER` Allow subclasses access to the status logger without creating another instance.
`protected StrSubstitutor` | `substitutor`
`protected static String` | `TEST_PREFIX` File name prefix for test configurations.

Constructor Summary
`ConfigurationFactory()`

Method Summary
`abstract Configuration` | `getConfiguration(ConfigurationSource source)`
`Configuration` | `getConfiguration(String name, URI configLocation)` Returns the Configuration.
`Configuration` | `getConfiguration(String name, URI configLocation, ClassLoader loader)` Returns the Configuration obtained using a given ClassLoader.
`protected ConfigurationSource` | `getInputFromResource(String resource, ClassLoader loader)` Retrieve the configuration via the ClassLoader.
`protected ConfigurationSource` | `getInputFromString(String config, ClassLoader loader)` Load the configuration from the location represented by the String.
`protected ConfigurationSource` | `getInputFromUri(URI configLocation)` Load the configuration from a URI.
`static ConfigurationFactory` | `getInstance()` Returns the ConfigurationFactory.
`protected abstract String[]` | `getSupportedTypes()`
`protected boolean` | `isActive()`
`static void` | `removeConfigurationFactory(ConfigurationFactory factory)` Remove the ConfigurationFactory.
`static void` | `resetConfigurationFactory()` Reset the ConfigurationFactory to the default.
`static void` | `setConfigurationFactory(ConfigurationFactory factory)` Set the configuration factory.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### CONFIGURATION_FACTORY_PROPERTY

    public static final String CONFIGURATION_FACTORY_PROPERTY

  Allow the ConfigurationFactory class to be specified as a system property.

  See Also:
    Constant Field Values

### CONFIGURATION_FILE_PROPERTY

    public static final String CONFIGURATION_FILE_PROPERTY

  Allow the location of the configuration file to be specified as a system property.

  See Also:
    Constant Field Values

### CATEGORY

    public static final String CATEGORY

  Plugin category used to inject a ConfigurationFactory `Plugin` class.

  Since:
    2.1
  See Also:
    Constant Field Values

### LOGGER

    protected static final org.apache.logging.log4j.Logger LOGGER

  Allow subclasses access to the status logger without creating another instance.

### TEST_PREFIX

    protected static final String TEST_PREFIX

  File name prefix for test configurations.

  See Also:
    Constant Field Values

### DEFAULT_PREFIX

    protected static final String DEFAULT_PREFIX

  File name prefix for standard configurations.

  See Also:
    Constant Field Values

### substitutor

    protected final StrSubstitutor substitutor

Constructor Detail

### ConfigurationFactory

    public ConfigurationFactory()

Method Detail

### getInstance

    public static ConfigurationFactory getInstance()

  Returns the ConfigurationFactory.

  Returns:
    the ConfigurationFactory.

### setConfigurationFactory

    public static void setConfigurationFactory(ConfigurationFactory factory)

  Set 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()

  Reset 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)

  Remove 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 String[] getSupportedTypes()

### isActive

    protected boolean isActive()

### getConfiguration

    public abstract Configuration getConfiguration(ConfigurationSource source)

### getConfiguration

    public Configuration getConfiguration(String name,
                                          URI configLocation)

  Returns the Configuration.

  Parameters:
    `name` - The configuration name.
    `configLocation` - The configuration location.
  Returns:
    The Configuration.

### getConfiguration

    public Configuration getConfiguration(String name,
                                          URI configLocation,
                                          ClassLoader loader)

  Returns the Configuration obtained using a given ClassLoader.

  Parameters:
    `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.
  Since:
    2.1

### getInputFromUri

    protected ConfigurationSource getInputFromUri(URI configLocation)

  Load the configuration from a URI.

  Parameters:
    `configLocation` - A URI representing the location of the configuration.
  Returns:
    The ConfigurationSource for the configuration.

### getInputFromString

    protected ConfigurationSource getInputFromString(String config,
                                                     ClassLoader loader)

  Load 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.

### getInputFromResource

    protected ConfigurationSource getInputFromResource(String resource,
                                                       ClassLoader loader)

  Retrieve the configuration via the ClassLoader.

  Parameters:
    `resource` - The resource to load.
    `loader` - The default ClassLoader to use.
  Returns:
    The ConfigurationSource for the configuration.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1999-2015 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.