From 20c1c617ef8a085914dedfeb9954dc69db3529e0 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 6 Aug 2015 13:30:35 +0200 Subject: [PATCH] Polish See gh-3684 --- .../boot/logging/LoggingApplicationListener.java | 7 ++++++- .../META-INF/additional-spring-configuration-metadata.json | 7 +++++++ .../boot/logging/LoggingApplicationListenerTests.java | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java index 60ec5fa87b..e1081a9225 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java @@ -192,13 +192,18 @@ public class LoggingApplicationListener implements GenericApplicationListener { } if (System.getProperty(EXCEPTION_CONVERSION_WORD) == null) { System.setProperty(EXCEPTION_CONVERSION_WORD, - environment.getProperty("logging.exception-conversion-word", "%rEx")); + getExceptionConversionWord(environment)); } initializeEarlyLoggingLevel(environment); initializeSystem(environment, this.loggingSystem); initializeFinalLoggingLevels(environment, this.loggingSystem); } + private String getExceptionConversionWord(ConfigurableEnvironment environment) { + RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment, "logging."); + return resolver.getProperty("exception-conversion-word", "%rEx"); + } + private void initializeEarlyLoggingLevel(ConfigurableEnvironment environment) { if (this.parseArgs && this.springBootLogging == null) { if (environment.containsProperty("debug")) { diff --git a/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json index dca43aa322..6ace93c925 100644 --- a/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -29,6 +29,13 @@ "description": "Location of the logging configuration file.", "sourceType": "org.springframework.boot.logging.LoggingApplicationListener" }, + { + "name": "logging.exception-conversion-word", + "type": "java.lang.String", + "description": "Conversion word used when logging exceptions.", + "defaultValue": "%rEx", + "sourceType": "org.springframework.boot.logging.LoggingApplicationListener" + }, { "name": "logging.file", "type": "java.lang.String", diff --git a/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java b/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java index f223e81d6a..dea4598beb 100644 --- a/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java @@ -332,7 +332,7 @@ public class LoggingApplicationListenerTests { @Test public void overrideExceptionConversionWord() throws Exception { EnvironmentTestUtils.addEnvironment(this.context, - "logging.exception-conversion-word:%ex"); + "logging.exceptionConversionWord:%ex"); this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); this.outputCapture.expect(containsString("Hello world"));