1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.logging.log4j.core.config.properties;
18
19 import java.io.IOException;
20
21 import org.apache.logging.log4j.core.LoggerContext;
22 import org.apache.logging.log4j.core.config.Configuration;
23 import org.apache.logging.log4j.core.config.ConfigurationSource;
24 import org.apache.logging.log4j.core.config.Reconfigurable;
25 import org.apache.logging.log4j.core.config.builder.api.Component;
26 import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
27
28
29
30
31
32 public class PropertiesConfiguration extends BuiltConfiguration implements Reconfigurable {
33
34
35 public PropertiesConfiguration(final LoggerContext loggerContext, final ConfigurationSource source, final Component root) {
36 super(loggerContext, source, root);
37 }
38
39 @Override
40 public Configuration reconfigure() {
41 try {
42 final ConfigurationSource source = getConfigurationSource().resetInputStream();
43 if (source == null) {
44 return null;
45 }
46 final PropertiesConfigurationFactory factory = new PropertiesConfigurationFactory();
47 final PropertiesConfiguration config = factory.getConfiguration(getLoggerContext(), source);
48 return config == null || config.getState() != State.INITIALIZING ? null : config;
49 } catch (final IOException ex) {
50 LOGGER.error("Cannot locate file {}: {}", getConfigurationSource(), ex);
51 }
52 return null;
53 }
54
55
56 }