From 2cb4403cd0a34102c8df3c724ad13f9950510fe4 Mon Sep 17 00:00:00 2001 From: Mohamed Rifni Date: Tue, 19 Mar 2019 12:37:11 +0000 Subject: [PATCH 1/2] 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 From b894696efb27a55e961b2fe74f89057804766fcd Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 29 Mar 2019 15:57:06 +0100 Subject: [PATCH 2/2] Polish "Automatically detect log4j2.properties" Closes gh-16262 --- .../boot/logging/log4j2/Log4J2LoggingSystem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 920ba26874..2a81ededb8 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 @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.