From 2cb4403cd0a34102c8df3c724ad13f9950510fe4 Mon Sep 17 00:00:00 2001 From: Mohamed Rifni Date: Tue, 19 Mar 2019 12:37:11 +0000 Subject: [PATCH] Automatically detect log4j2.properties See gh-16262 --- .../boot/logging/log4j2/Log4J2LoggingSystem.java | 1 + .../boot/logging/log4j2/Log4J2LoggingSystemTests.java | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java index 4e6293f714..920ba26874 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java @@ -112,6 +112,7 @@ public class Log4J2LoggingSystem extends Slf4JLoggingSystem { private String[] getCurrentlySupportedConfigLocations() { List supportedConfigLocations = new ArrayList<>(); + supportedConfigLocations.add("log4j2.properties"); if (isClassAvailable("com.fasterxml.jackson.dataformat.yaml.YAMLParser")) { Collections.addAll(supportedConfigLocations, "log4j2.yaml", "log4j2.yml"); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java index 55a5e394ef..2b7fa1c151 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystemTests.java @@ -211,7 +211,7 @@ public class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests { @Test public void configLocationsWithNoExtraDependencies() { assertThat(this.loggingSystem.getStandardConfigLocations()) - .contains("log4j2.xml"); + .contains("log4j2.properties", "log4j2.xml"); } @Test @@ -241,7 +241,8 @@ public class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests { @Test public void springConfigLocations() { 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