Search in sources :

Example 1 with ConfigurationFactory

use of org.apache.logging.log4j.core.config.ConfigurationFactory in project logging-log4j2 by apache.

the class CompositeConfiguration method reconfigure.

@Override
public Configuration reconfigure() {
    LOGGER.debug("Reconfiguring composite configuration");
    final List<AbstractConfiguration> configs = new ArrayList<>();
    final ConfigurationFactory factory = ConfigurationFactory.getInstance();
    for (final AbstractConfiguration config : configurations) {
        final ConfigurationSource source = config.getConfigurationSource();
        final URI sourceURI = source.getURI();
        Configuration currentConfig;
        if (sourceURI != null) {
            LOGGER.warn("Unable to determine URI for configuration {}, changes to it will be ignored", config.getName());
            currentConfig = factory.getConfiguration(getLoggerContext(), config.getName(), sourceURI);
            if (currentConfig == null) {
                LOGGER.warn("Unable to reload configuration {}, changes to it will be ignored", config.getName());
                currentConfig = config;
            }
        } else {
            currentConfig = config;
        }
        configs.add((AbstractConfiguration) currentConfig);
    }
    return new CompositeConfiguration(configs);
}
Also used : AbstractConfiguration(org.apache.logging.log4j.core.config.AbstractConfiguration) ConfigurationSource(org.apache.logging.log4j.core.config.ConfigurationSource) StatusConfiguration(org.apache.logging.log4j.core.config.status.StatusConfiguration) Configuration(org.apache.logging.log4j.core.config.Configuration) AbstractConfiguration(org.apache.logging.log4j.core.config.AbstractConfiguration) ArrayList(java.util.ArrayList) ConfigurationFactory(org.apache.logging.log4j.core.config.ConfigurationFactory) URI(java.net.URI)

Aggregations

URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 AbstractConfiguration (org.apache.logging.log4j.core.config.AbstractConfiguration)1 Configuration (org.apache.logging.log4j.core.config.Configuration)1 ConfigurationFactory (org.apache.logging.log4j.core.config.ConfigurationFactory)1 ConfigurationSource (org.apache.logging.log4j.core.config.ConfigurationSource)1 StatusConfiguration (org.apache.logging.log4j.core.config.status.StatusConfiguration)1