diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java index 935f4aaf34a..23a37292a8f 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java @@ -42,6 +42,7 @@ public abstract class AbstractLoggingSystem extends LoggingSystem { @Override public void beforeInitialize() { + initializeWithSensibleDefaults(); } @Override @@ -53,7 +54,6 @@ public abstract class AbstractLoggingSystem extends LoggingSystem { return; } } - initializeWithSensibleDefaults(); } protected void initializeWithSensibleDefaults() { diff --git a/spring-boot/src/test/java/org/springframework/boot/logging/java/JavaLoggerSystemTests.java b/spring-boot/src/test/java/org/springframework/boot/logging/java/JavaLoggerSystemTests.java index 42d19ca6b4d..4c5e66432f5 100644 --- a/spring-boot/src/test/java/org/springframework/boot/logging/java/JavaLoggerSystemTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/logging/java/JavaLoggerSystemTests.java @@ -61,6 +61,7 @@ public class JavaLoggerSystemTests { @Test public void testCustomFormatter() throws Exception { + this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize(); this.logger.info("Hello world"); String output = this.output.toString().trim(); @@ -71,6 +72,7 @@ public class JavaLoggerSystemTests { @Test public void testSystemPropertyInitializesFormat() throws Exception { System.setProperty("PID", "1234"); + this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize("classpath:" + ClassUtils.addResourcePathToPackagePath(getClass(), "logging.properties")); @@ -83,6 +85,7 @@ public class JavaLoggerSystemTests { @Test public void testNonDefaultConfigLocation() throws Exception { + this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize("classpath:logging-nondefault.properties"); this.logger.info("Hello world"); String output = this.output.toString().trim(); @@ -91,16 +94,19 @@ public class JavaLoggerSystemTests { @Test(expected = IllegalStateException.class) public void testNonexistentConfigLocation() throws Exception { + this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize("classpath:logging-nonexistent.properties"); } @Test(expected = IllegalArgumentException.class) public void testNullConfigLocation() throws Exception { + this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize(null); } @Test public void setLevel() throws Exception { + this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize(); this.logger.debug("Hello"); this.loggingSystem.setLogLevel("org.springframework.boot", LogLevel.DEBUG); diff --git a/spring-boot/src/test/java/org/springframework/boot/logging/log4j/Log4JLoggingSystemTests.java b/spring-boot/src/test/java/org/springframework/boot/logging/log4j/Log4JLoggingSystemTests.java index b39771b607f..b6208c76af5 100644 --- a/spring-boot/src/test/java/org/springframework/boot/logging/log4j/Log4JLoggingSystemTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/logging/log4j/Log4JLoggingSystemTests.java @@ -58,6 +58,7 @@ public class Log4JLoggingSystemTests { @Test public void testNonDefaultConfigLocation() throws Exception { + this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize("classpath:log4j-nondefault.properties"); this.logger.info("Hello world"); String output = this.output.toString().trim(); @@ -67,16 +68,19 @@ public class Log4JLoggingSystemTests { @Test(expected = IllegalStateException.class) public void testNonexistentConfigLocation() throws Exception { + this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize("classpath:log4j-nonexistent.xml"); } @Test(expected = IllegalArgumentException.class) public void testNullConfigLocation() throws Exception { + this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize(null); } @Test public void setLevel() throws Exception { + this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize(); this.logger.debug("Hello"); this.loggingSystem.setLogLevel("org.springframework.boot", LogLevel.DEBUG); diff --git a/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java b/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java index 812567cf67d..27e123bb37d 100644 --- a/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java @@ -59,6 +59,7 @@ public class LogbackLoggingSystemTests { @Test public void testNonDefaultConfigLocation() throws Exception { + this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize("classpath:logback-nondefault.xml"); this.logger.info("Hello world"); String output = this.output.toString().trim(); @@ -68,16 +69,19 @@ public class LogbackLoggingSystemTests { @Test(expected = IllegalStateException.class) public void testNonexistentConfigLocation() throws Exception { + this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize("classpath:logback-nonexistent.xml"); } @Test(expected = IllegalArgumentException.class) public void testNullConfigLocation() throws Exception { + this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize(null); } @Test public void setLevel() throws Exception { + this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize(); this.logger.debug("Hello"); this.loggingSystem.setLogLevel("org.springframework.boot", LogLevel.DEBUG);