1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.log4j.config;
19
20 import org.apache.logging.log4j.core.LoggerContext;
21 import org.apache.logging.log4j.core.config.Configuration;
22 import org.apache.logging.log4j.core.config.ConfigurationFactory;
23 import org.apache.logging.log4j.core.config.ConfigurationSource;
24 import org.apache.logging.log4j.core.config.Order;
25 import org.apache.logging.log4j.core.config.plugins.Plugin;
26 import org.apache.logging.log4j.util.PropertiesUtil;
27
28
29
30
31 @Plugin(name = "Log4j1PropertiesConfigurationFactory", category = ConfigurationFactory.CATEGORY)
32 @Order(2)
33 public class PropertiesConfigurationFactory extends ConfigurationFactory {
34
35 static final String FILE_EXTENSION = ".properties";
36
37
38
39
40 protected static final String TEST_PREFIX = "log4j-test";
41
42
43
44
45 protected static final String DEFAULT_PREFIX = "log4j";
46
47 @Override
48 protected String[] getSupportedTypes() {
49 if (!PropertiesUtil.getProperties().getBooleanProperty(ConfigurationFactory.LOG4J1_EXPERIMENTAL, Boolean.FALSE)) {
50 return null;
51 }
52 return new String[] { FILE_EXTENSION };
53 }
54
55 @Override
56 public Configuration getConfiguration(LoggerContext loggerContext, ConfigurationSource source) {
57 int interval = PropertiesUtil.getProperties().getIntegerProperty(Log4j1Configuration.MONITOR_INTERVAL, 0);
58 return new PropertiesConfiguration(loggerContext, source, interval);
59 }
60
61 @Override
62 protected String getTestPrefix() {
63 return TEST_PREFIX;
64 }
65
66 @Override
67 protected String getDefaultPrefix() {
68 return DEFAULT_PREFIX;
69 }
70
71 @Override
72 protected String getVersion() {
73 return LOG4J1_VERSION;
74 }
75 }