diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java index a36b72e18c7..91ff4b64ee5 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java @@ -22,7 +22,6 @@ import java.util.concurrent.Callable; import org.apache.commons.logging.Log; -import org.springframework.boot.logging.LoggingSystemProperties; import org.springframework.context.ApplicationContext; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; @@ -109,7 +108,7 @@ class StartupInfoLogger { } private String getPid() { - return getValue(" with PID ", () -> System.getProperty(LoggingSystemProperties.PID_KEY)); + return getValue(" with PID ", () -> new ApplicationPid().toString()); } private String getContext() { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java index e83274e57fc..9e4a68b5467 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java @@ -128,10 +128,12 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem { stopAndReset(context); LogbackConfigurator configurator = new LogbackConfigurator(context); Environment environment = initializationContext.getEnvironment(); - context.putProperty(LoggingSystemProperties.LOG_LEVEL_PATTERN, environment.resolvePlaceholders( - "${logging.pattern.level:${LOG_LEVEL_PATTERN:%5p}}")); - context.putProperty(LoggingSystemProperties.LOG_DATEFORMAT_PATTERN, environment.resolvePlaceholders( - "${logging.pattern.dateformat:${LOG_DATEFORMAT_PATTERN:yyyy-MM-dd HH:mm:ss.SSS}}")); + context.putProperty(LoggingSystemProperties.LOG_LEVEL_PATTERN, + environment.resolvePlaceholders( + "${logging.pattern.level:${LOG_LEVEL_PATTERN:%5p}}")); + context.putProperty(LoggingSystemProperties.LOG_DATEFORMAT_PATTERN, + environment.resolvePlaceholders( + "${logging.pattern.dateformat:${LOG_DATEFORMAT_PATTERN:yyyy-MM-dd HH:mm:ss.SSS}}")); new DefaultLogbackConfiguration(initializationContext, logFile) .apply(configurator); context.setPackagingDataEnabled(true); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java index ed7fd456a46..1bd32efbae7 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java @@ -482,13 +482,18 @@ public class LoggingApplicationListenerTests { "logging.pattern.file=file", "logging.pattern.level=level"); this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); - assertThat(System.getProperty(LoggingSystemProperties.CONSOLE_LOG_PATTERN)).isEqualTo("console"); - assertThat(System.getProperty(LoggingSystemProperties.FILE_LOG_PATTERN)).isEqualTo("file"); + assertThat(System.getProperty(LoggingSystemProperties.CONSOLE_LOG_PATTERN)) + .isEqualTo("console"); + assertThat(System.getProperty(LoggingSystemProperties.FILE_LOG_PATTERN)) + .isEqualTo("file"); assertThat(System.getProperty(LoggingSystemProperties.EXCEPTION_CONVERSION_WORD)) .isEqualTo("conversion"); - assertThat(System.getProperty(LoggingSystemProperties.LOG_FILE)).isEqualTo("target/log"); - assertThat(System.getProperty(LoggingSystemProperties.LOG_LEVEL_PATTERN)).isEqualTo("level"); - assertThat(System.getProperty(LoggingSystemProperties.LOG_PATH)).isEqualTo("path"); + assertThat(System.getProperty(LoggingSystemProperties.LOG_FILE)) + .isEqualTo("target/log"); + assertThat(System.getProperty(LoggingSystemProperties.LOG_LEVEL_PATTERN)) + .isEqualTo("level"); + assertThat(System.getProperty(LoggingSystemProperties.LOG_PATH)) + .isEqualTo("path"); assertThat(System.getProperty(LoggingSystemProperties.PID_KEY)).isNotNull(); } @@ -499,7 +504,8 @@ public class LoggingApplicationListenerTests { "logging.pattern.console=console ${pid}"); this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); - assertThat(System.getProperty(LoggingSystemProperties.CONSOLE_LOG_PATTERN)).isEqualTo("console ${pid}"); + assertThat(System.getProperty(LoggingSystemProperties.CONSOLE_LOG_PATTERN)) + .isEqualTo("console ${pid}"); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/LogFileTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/LogFileTests.java index 8479f80787d..a39b19d9a2f 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/LogFileTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/LogFileTests.java @@ -51,7 +51,8 @@ public class LogFileTests { Properties properties = new Properties(); logFile.applyTo(properties); assertThat(logFile.toString()).isEqualTo("log.file"); - assertThat(properties.getProperty(LoggingSystemProperties.LOG_FILE)).isEqualTo("log.file"); + assertThat(properties.getProperty(LoggingSystemProperties.LOG_FILE)) + .isEqualTo("log.file"); assertThat(properties.getProperty(LoggingSystemProperties.LOG_PATH)).isNull(); } @@ -62,8 +63,10 @@ public class LogFileTests { Properties properties = new Properties(); logFile.applyTo(properties); assertThat(logFile.toString()).isEqualTo("logpath/spring.log"); - assertThat(properties.getProperty(LoggingSystemProperties.LOG_FILE)).isEqualTo("logpath/spring.log"); - assertThat(properties.getProperty(LoggingSystemProperties.LOG_PATH)).isEqualTo("logpath"); + assertThat(properties.getProperty(LoggingSystemProperties.LOG_FILE)) + .isEqualTo("logpath/spring.log"); + assertThat(properties.getProperty(LoggingSystemProperties.LOG_PATH)) + .isEqualTo("logpath"); } @Test @@ -73,8 +76,10 @@ public class LogFileTests { Properties properties = new Properties(); logFile.applyTo(properties); assertThat(logFile.toString()).isEqualTo("log.file"); - assertThat(properties.getProperty(LoggingSystemProperties.LOG_FILE)).isEqualTo("log.file"); - assertThat(properties.getProperty(LoggingSystemProperties.LOG_PATH)).isEqualTo("logpath"); + assertThat(properties.getProperty(LoggingSystemProperties.LOG_FILE)) + .isEqualTo("log.file"); + assertThat(properties.getProperty(LoggingSystemProperties.LOG_PATH)) + .isEqualTo("logpath"); } private PropertyResolver getPropertyResolver(String file, String path) { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java index 45ca6273b16..e462af5649d 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java @@ -420,7 +420,8 @@ public class LogbackLoggingSystemTests extends AbstractLoggingSystemTests { LogFile logFile = getLogFile(tmpDir() + "/example.log", null, false); this.loggingSystem.initialize(this.initializationContext, "classpath:logback-nondefault.xml", logFile); - assertThat(System.getProperty(LoggingSystemProperties.LOG_FILE)).endsWith("example.log"); + assertThat(System.getProperty(LoggingSystemProperties.LOG_FILE)) + .endsWith("example.log"); } @Test