Commit 2cb4403c authored by Mohamed Rifni's avatar Mohamed Rifni Committed by Stephane Nicoll

Automatically detect log4j2.properties

See gh-16262
parent 1261c396
...@@ -112,6 +112,7 @@ public class Log4J2LoggingSystem extends Slf4JLoggingSystem { ...@@ -112,6 +112,7 @@ public class Log4J2LoggingSystem extends Slf4JLoggingSystem {
private String[] getCurrentlySupportedConfigLocations() { private String[] getCurrentlySupportedConfigLocations() {
List<String> supportedConfigLocations = new ArrayList<>(); List<String> supportedConfigLocations = new ArrayList<>();
supportedConfigLocations.add("log4j2.properties");
if (isClassAvailable("com.fasterxml.jackson.dataformat.yaml.YAMLParser")) { if (isClassAvailable("com.fasterxml.jackson.dataformat.yaml.YAMLParser")) {
Collections.addAll(supportedConfigLocations, "log4j2.yaml", "log4j2.yml"); Collections.addAll(supportedConfigLocations, "log4j2.yaml", "log4j2.yml");
} }
......
...@@ -211,7 +211,7 @@ public class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests { ...@@ -211,7 +211,7 @@ public class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests {
@Test @Test
public void configLocationsWithNoExtraDependencies() { public void configLocationsWithNoExtraDependencies() {
assertThat(this.loggingSystem.getStandardConfigLocations()) assertThat(this.loggingSystem.getStandardConfigLocations())
.contains("log4j2.xml"); .contains("log4j2.properties", "log4j2.xml");
} }
@Test @Test
...@@ -241,7 +241,8 @@ public class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests { ...@@ -241,7 +241,8 @@ public class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests {
@Test @Test
public void springConfigLocations() { public void springConfigLocations() {
String[] locations = getSpringConfigLocations(this.loggingSystem); String[] locations = getSpringConfigLocations(this.loggingSystem);
assertThat(locations).isEqualTo(new String[] { "log4j2-spring.xml" }); assertThat(locations).isEqualTo(
new String[] { "log4j2-spring.properties", "log4j2-spring.xml" });
} }
@Test @Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment