|
73 | 73 | * @author Andy Wilkinson
|
74 | 74 | * @author Alexander Heusingfeld
|
75 | 75 | * @author Ben Hale
|
| 76 | + * @author Ralph Goers |
76 | 77 | * @since 1.2.0
|
77 | 78 | */
|
78 | 79 | public class Log4J2LoggingSystem extends AbstractLoggingSystem {
|
@@ -125,37 +126,29 @@ public Log4J2LoggingSystem(ClassLoader classLoader) {
|
125 | 126 |
|
126 | 127 | @Override
|
127 | 128 | protected String[] getStandardConfigLocations() {
|
128 |
| - return getCurrentlySupportedConfigLocations(); |
129 |
| - } |
130 |
| - |
131 |
| - private String[] getCurrentlySupportedConfigLocations() { |
132 |
| - List<String> supportedConfigLocations = new ArrayList<>(); |
133 |
| - addTestFiles(supportedConfigLocations); |
134 |
| - supportedConfigLocations.add("log4j2.properties"); |
| 129 | + List<String> locations = new ArrayList<>(); |
| 130 | + locations.add("log4j2-test.properties"); |
135 | 131 | if (isClassAvailable("com.fasterxml.jackson.dataformat.yaml.YAMLParser")) {
|
136 |
| - Collections.addAll(supportedConfigLocations, "log4j2.yaml", "log4j2.yml"); |
| 132 | + Collections.addAll(locations, "log4j2-test.yaml", "log4j2-test.yml"); |
137 | 133 | }
|
138 | 134 | if (isClassAvailable("com.fasterxml.jackson.databind.ObjectMapper")) {
|
139 |
| - Collections.addAll(supportedConfigLocations, "log4j2.json", "log4j2.jsn"); |
140 |
| - } |
141 |
| - supportedConfigLocations.add("log4j2.xml"); |
142 |
| - PropertiesUtil props = new PropertiesUtil(new Properties()); |
143 |
| - String location = props.getStringProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY); |
144 |
| - if (location != null) { |
145 |
| - supportedConfigLocations.add(location); |
| 135 | + Collections.addAll(locations, "log4j2-test.json", "log4j2-test.jsn"); |
146 | 136 | }
|
147 |
| - return StringUtils.toStringArray(supportedConfigLocations); |
148 |
| - } |
149 |
| - |
150 |
| - private void addTestFiles(List<String> supportedConfigLocations) { |
151 |
| - supportedConfigLocations.add("log4j2-test.properties"); |
| 137 | + locations.add("log4j2-test.xml"); |
| 138 | + locations.add("log4j2.properties"); |
152 | 139 | if (isClassAvailable("com.fasterxml.jackson.dataformat.yaml.YAMLParser")) {
|
153 |
| - Collections.addAll(supportedConfigLocations, "log4j2-test.yaml", "log4j2-test.yml"); |
| 140 | + Collections.addAll(locations, "log4j2.yaml", "log4j2.yml"); |
154 | 141 | }
|
155 | 142 | if (isClassAvailable("com.fasterxml.jackson.databind.ObjectMapper")) {
|
156 |
| - Collections.addAll(supportedConfigLocations, "log4j2-test.json", "log4j2-test.jsn"); |
| 143 | + Collections.addAll(locations, "log4j2.json", "log4j2.jsn"); |
| 144 | + } |
| 145 | + locations.add("log4j2.xml"); |
| 146 | + String propertyDefinedLocation = new PropertiesUtil(new Properties()) |
| 147 | + .getStringProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY); |
| 148 | + if (propertyDefinedLocation != null) { |
| 149 | + locations.add(propertyDefinedLocation); |
157 | 150 | }
|
158 |
| - supportedConfigLocations.add("log4j2-test.xml"); |
| 151 | + return StringUtils.toStringArray(locations); |
159 | 152 | }
|
160 | 153 |
|
161 | 154 | protected boolean isClassAvailable(String className) {
|
|
0 commit comments