From a12f6be21f99dc3db73ab3d61fe52f8349087e69 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Sun, 4 Nov 2018 17:03:45 -0500 Subject: [PATCH 01/13] Renamed `logging.file` to `logging.file.name` To prevent issues with YAML parsing the `logging.file`, the property `logging.file` should be renamed, because of child properties logging.file.max-history and logging.file.max-size. This (partially) fixes #12510 --- .../logging/LogFileWebEndpointAutoConfiguration.java | 4 ++-- .../LogFileWebEndpointDocumentationTests.java | 2 +- .../logging/LogFileWebEndpointAutoConfigurationTests.java | 4 ++-- .../boot/actuate/logging/LogFileWebEndpoint.java | 2 +- .../boot/actuate/logging/LogFileWebEndpointTests.java | 4 ++-- .../logging/LogFileWebEndpointWebIntegrationTests.java | 2 +- .../main/asciidoc/appendix-application-properties.adoc | 2 +- .../spring-boot-docs/src/main/asciidoc/howto.adoc | 8 ++++---- .../src/main/asciidoc/production-ready-features.adoc | 2 +- .../src/main/asciidoc/spring-boot-features.adoc | 6 +++--- .../boot/context/logging/LoggingApplicationListener.java | 2 +- .../java/org/springframework/boot/logging/LogFile.java | 6 +++--- .../additional-spring-configuration-metadata.json | 2 +- .../boot/builder/SpringApplicationBuilderTests.java | 6 +++--- .../context/logging/LoggingApplicationListenerTests.java | 8 ++++---- .../org/springframework/boot/logging/LogFileTests.java | 2 +- .../src/main/resources/application.properties | 2 +- 17 files changed, 32 insertions(+), 32 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java index 51c82fda5ea6..74917ef0a082 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java @@ -60,11 +60,11 @@ private static class LogFileCondition extends SpringBootCondition { public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { Environment environment = context.getEnvironment(); - String config = environment.resolvePlaceholders("${logging.file:}"); + String config = environment.resolvePlaceholders("${logging.file.name:}"); ConditionMessage.Builder message = ConditionMessage.forCondition("Log File"); if (StringUtils.hasText(config)) { return ConditionOutcome - .match(message.found("logging.file").items(config)); + .match(message.found("logging.file.name").items(config)); } config = environment.resolvePlaceholders("${logging.path:}"); if (StringUtils.hasText(config)) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LogFileWebEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LogFileWebEndpointDocumentationTests.java index dd0c0ed71c1f..3ef69af3e5e4 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LogFileWebEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LogFileWebEndpointDocumentationTests.java @@ -34,7 +34,7 @@ * * @author Andy Wilkinson */ -@TestPropertySource(properties = "logging.file=src/test/resources/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/sample.log") +@TestPropertySource(properties = "logging.file.name=src/test/resources/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/sample.log") public class LogFileWebEndpointDocumentationTests extends MockMvcEndpointDocumentationTests { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java index f426ad24b3f0..b8c8296d67b1 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java @@ -49,7 +49,7 @@ public class LogFileWebEndpointAutoConfigurationTests { @Test public void logFileWebEndpointIsAutoConfiguredWhenLoggingFileIsSet() { - this.contextRunner.withPropertyValues("logging.file:test.log").run( + this.contextRunner.withPropertyValues("logging.file.name:test.log").run( (context) -> assertThat(context).hasSingleBean(LogFileWebEndpoint.class)); } @@ -71,7 +71,7 @@ public void logFileWebEndpointIsAutoConfiguredWhenExternalFileIsSet() { @Test public void logFileWebEndpointCanBeDisabled() { this.contextRunner - .withPropertyValues("logging.file:test.log", + .withPropertyValues("logging.file.name:test.log", "management.endpoint.logfile.enabled:false") .run((context) -> assertThat(context) .hasSingleBean(LogFileWebEndpoint.class)); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LogFileWebEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LogFileWebEndpoint.java index d0e00c66cc3f..2d21bd9e5bed 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LogFileWebEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LogFileWebEndpoint.java @@ -70,7 +70,7 @@ private Resource getLogFileResource() { } LogFile logFile = LogFile.get(this.environment); if (logFile == null) { - logger.debug("Missing 'logging.file' or 'logging.path' properties"); + logger.debug("Missing 'logging.file.name' or 'logging.path' properties"); return null; } return new FileSystemResource(logFile.toString()); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointTests.java index 22d27da724d8..6df25e6daa26 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointTests.java @@ -63,13 +63,13 @@ public void nullResponseWithoutLogFile() { @Test public void nullResponseWithMissingLogFile() { - this.environment.setProperty("logging.file", "no_test.log"); + this.environment.setProperty("logging.file.name", "no_test.log"); assertThat(this.endpoint.logFile()).isNull(); } @Test public void resourceResponseWithLogFile() throws Exception { - this.environment.setProperty("logging.file", this.logFile.getAbsolutePath()); + this.environment.setProperty("logging.file.name", this.logFile.getAbsolutePath()); Resource resource = this.endpoint.logFile(); assertThat(resource).isNotNull(); assertThat(StreamUtils.copyToString(resource.getInputStream(), diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointWebIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointWebIntegrationTests.java index 7c713c3610b3..6cd9f4f22cde 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointWebIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointWebIntegrationTests.java @@ -65,7 +65,7 @@ public void getRequestProduces404ResponseWhenLogFileNotFound() { @Test public void getRequestProducesResponseWithLogFile() { - TestPropertyValues.of("logging.file:" + this.logFile.getAbsolutePath()) + TestPropertyValues.of("logging.file.name:" + this.logFile.getAbsolutePath()) .applyTo(context); client.get().uri("/actuator/logfile").exchange().expectStatus().isOk() .expectBody(String.class).isEqualTo("--TEST--"); diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 03069eecd9e4..854ddba8557c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -37,7 +37,7 @@ content into your application. Rather, pick only the properties that you need. # LOGGING logging.config= # Location of the logging configuration file. For instance, `classpath:logback.xml` for Logback. logging.exception-conversion-word=%wEx # Conversion word used when logging exceptions. - logging.file= # Log file name (for instance, `myapp.log`). Names can be an exact location or relative to the current directory. + logging.file.name= # Log file name (for instance, `myapp.log`). Names can be an exact location or relative to the current directory. logging.file.max-history=0 # Maximum of archive log files to keep. Only supported with the default logback setup. logging.file.max-size=10MB # Maximum log file size. Only supported with the default logback setup. logging.group.*= # Log groups to quickly change multiple loggers at the same time. For instance, `logging.level.db=org.hibernate,org.springframework.jdbc`. diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc index dccd955f1361..cbdfeec98c9b 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -1531,7 +1531,7 @@ in the following example: ---- You can also set the location of a file to which to write the log (in addition to the -console) by using "logging.file". +console) by using "logging.file.name". To configure the more fine-grained settings of a logging system, you need to use the native configuration format supported by the `LoggingSystem` in question. By default, Spring Boot @@ -1561,7 +1561,7 @@ If you look at `base.xml` in the spring-boot jar, you can see that it uses some useful System properties that the `LoggingSystem` takes care of creating for you: * `${PID}`: The current process ID. -* `${LOG_FILE}`: Whether `logging.file` was set in Boot's external configuration. +* `${LOG_FILE}`: Whether `logging.file.name` was set in Boot's external configuration. * `${LOG_PATH}`: Whether `logging.path` (representing a directory for log files to live in) was set in Boot's external configuration. * `${LOG_EXCEPTION_CONVERSION_WORD}`: Whether `logging.exception-conversion-word` was set @@ -1595,12 +1595,12 @@ shown in the following example: ---- -You also need to add `logging.file` to your `application.properties`, as shown in the +You also need to add `logging.file.name` to your `application.properties`, as shown in the following example: [source,properties,indent=0,subs="verbatim,quotes,attributes"] ---- - logging.file=myapplication.log + logging.file.name=myapplication.log ---- diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc index 89e3cd573ff3..8124d05724e5 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc @@ -164,7 +164,7 @@ use the following additional endpoints: |Yes |`logfile` -|Returns the contents of the logfile (if `logging.file` or `logging.path` properties have +|Returns the contents of the logfile (if `logging.file.name` or `logging.path` properties have been set). Supports the use of the HTTP `Range` header to retrieve part of the log file's content. |Yes diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 67d8aae8688c..a8120c13a0b6 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -1686,7 +1686,7 @@ The following colors and styles are supported: === File Output By default, Spring Boot logs only to the console and does not write log files. If you want to write log files in addition to the console output, you need to set a -`logging.file` or `logging.path` property (for example, in your +`logging.file.name` or `logging.path` property (for example, in your `application.properties`). The following table shows how the `logging.*` properties can be used together: @@ -1694,7 +1694,7 @@ The following table shows how the `logging.*` properties can be used together: .Logging properties [cols="1,1,1,4"] |=== -|`logging.file` |`logging.path` |Example |Description +|`logging.file.name` |`logging.path` |Example |Description |_(none)_ |_(none)_ @@ -1835,7 +1835,7 @@ To help with the customization, some other properties are transferred from the S |`LOG_EXCEPTION_CONVERSION_WORD` |The conversion word used when logging exceptions. -|`logging.file` +|`logging.file.name` |`LOG_FILE` |If defined, it is used in the default log configuration. diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java index cb180b2d357f..b12f508a5943 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java @@ -69,7 +69,7 @@ * properties you can set {@link #setParseArgs(boolean) parseArgs} to {@code false}. *

* By default, log output is only written to the console. If a log file is required the - * {@code logging.path} and {@code logging.file} properties can be used. + * {@code logging.path} and {@code logging.file.name} properties can be used. *

* Some system properties may be set as side effects, and these can be useful if the * logging configuration supports placeholders (i.e. log4j or logback): diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java index 39d8f050d6f4..a47f6ca31bf0 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java @@ -25,8 +25,8 @@ /** * A reference to a log output file. Log output files are specified using - * {@code logging.file} or {@code logging.path} {@link Environment} properties. If the - * {@code logging.file} property is not specified {@code "spring.log"} will be written in + * {@code logging.file.name} or {@code logging.path} {@link Environment} properties. If the + * {@code logging.file.name} property is not specified {@code "spring.log"} will be written in * the {@code logging.path} directory. * * @author Phillip Webb @@ -39,7 +39,7 @@ public class LogFile { * The name of the Spring property that contains the name of the log file. Names can * be an exact location or relative to the current directory. */ - public static final String FILE_PROPERTY = "logging.file"; + public static final String FILE_PROPERTY = "logging.file.name"; /** * The name of the Spring property that contains the directory where log files are diff --git a/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 3a7236be4367..b846aea163ce 100644 --- a/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -68,7 +68,7 @@ "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener" }, { - "name": "logging.file", + "name": "logging.file.name", "type": "java.lang.String", "description": "Log file name (for instance, `myapp.log`). Names can be an exact location or relative to the current directory.", "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener" diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java index 2ee328983e47..6da0b0b9f928 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java @@ -100,13 +100,13 @@ public void propertiesAsProperties() { public void propertiesWithRepeatSeparator() { SpringApplicationBuilder application = new SpringApplicationBuilder() .sources(ExampleConfig.class).contextClass(StaticApplicationContext.class) - .properties("one=c:\\logging.file", "two=a:b", "three:c:\\logging.file", + .properties("one=c:\\logging.file.name", "two=a:b", "three:c:\\logging.file.name", "four:a:b"); this.context = application.run(); ConfigurableEnvironment environment = this.context.getEnvironment(); - assertThat(environment.getProperty("one")).isEqualTo("c:\\logging.file"); + assertThat(environment.getProperty("one")).isEqualTo("c:\\logging.file.name"); assertThat(environment.getProperty("two")).isEqualTo("a:b"); - assertThat(environment.getProperty("three")).isEqualTo("c:\\logging.file"); + assertThat(environment.getProperty("three")).isEqualTo("c:\\logging.file.name"); assertThat(environment.getProperty("four")).isEqualTo("a:b"); } 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 58fbba16de5e..a533c4adb114 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 @@ -213,7 +213,7 @@ public void overrideConfigBroken() { public void addLogFileProperty() { TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "logging.config=classpath:logback-nondefault.xml", - "logging.file=target/foo.log"); + "logging.file.name=target/foo.log"); this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); Log logger = LogFactory.getLog(LoggingApplicationListenerTests.class); @@ -228,7 +228,7 @@ public void addLogFileProperty() { public void addLogFilePropertyWithDefault() { assertThat(new File("target/foo.log").exists()).isFalse(); TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, - "logging.file=target/foo.log"); + "logging.file.name=target/foo.log"); this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); Log logger = LogFactory.getLog(LoggingApplicationListenerTests.class); @@ -479,7 +479,7 @@ public void closingChildContextDoesNotCleanUpLoggingSystem() { @Test public void systemPropertiesAreSetForLoggingConfiguration() { TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, - "logging.exception-conversion-word=conversion", "logging.file=target/log", + "logging.exception-conversion-word=conversion", "logging.file.name=target/log", "logging.path=path", "logging.pattern.console=console", "logging.pattern.file=file", "logging.pattern.level=level"); this.initializer.initialize(this.context.getEnvironment(), @@ -524,7 +524,7 @@ public void environmentPropertiesResolvePlaceholders() { @Test public void logFilePropertiesCanReferenceSystemProperties() { TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, - "logging.file=target/${PID}.log"); + "logging.file.name=target/${PID}.log"); this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); assertThat(System.getProperty(LoggingSystemProperties.LOG_FILE)) 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 f99727db45cb..c5bc83d6423a 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 @@ -84,7 +84,7 @@ public void loggingFileAndPath() { private PropertyResolver getPropertyResolver(String file, String path) { Map properties = new LinkedHashMap<>(); - properties.put("logging.file", file); + properties.put("logging.file.name", file); properties.put("logging.path", path); PropertySource propertySource = new MapPropertySource("properties", properties); diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-actuator/src/main/resources/application.properties index bfc6809e10a0..09413b04851a 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/main/resources/application.properties +++ b/spring-boot-samples/spring-boot-sample-actuator/src/main/resources/application.properties @@ -3,7 +3,7 @@ service.name=Phil spring.security.user.name=user spring.security.user.password=password -# logging.file=/tmp/logs/app.log +# logging.file.name=/tmp/logs/app.log # logging.level.org.springframework.security=DEBUG management.server.address=127.0.0.1 From 46a55ca61eb1ef48380609066458c524456f12f5 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Sun, 4 Nov 2018 17:14:23 -0500 Subject: [PATCH 02/13] Added deprecation note for logging.file --- .../additional-spring-configuration-metadata.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json index b846aea163ce..efaeef25b930 100644 --- a/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -73,6 +73,16 @@ "description": "Log file name (for instance, `myapp.log`). Names can be an exact location or relative to the current directory.", "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener" }, + { + "name": "logging.file", + "type": "java.lang.String", + "description": "Log file name (for instance, `myapp.log`). Names can be an exact location or relative to the current directory.", + "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener", + "deprecation": { + "replacement": "logging.file.name", + "level": "error" + } + }, { "name": "logging.file.max-size", "type": "java.lang.String", From 640c2f3c41b4b20e2151ffa6694855b53546e76d Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Sun, 4 Nov 2018 17:25:02 -0500 Subject: [PATCH 03/13] Fixed formatting issue --- .../java/org/springframework/boot/logging/LogFile.java | 6 +++--- .../boot/builder/SpringApplicationBuilderTests.java | 4 ++-- .../context/logging/LoggingApplicationListenerTests.java | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java index a47f6ca31bf0..bcf68f4e09a2 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java @@ -25,9 +25,9 @@ /** * A reference to a log output file. Log output files are specified using - * {@code logging.file.name} or {@code logging.path} {@link Environment} properties. If the - * {@code logging.file.name} property is not specified {@code "spring.log"} will be written in - * the {@code logging.path} directory. + * {@code logging.file.name} or {@code logging.path} {@link Environment} properties. If + * the {@code logging.file.name} property is not specified {@code "spring.log"} will be + * written in the {@code logging.path} directory. * * @author Phillip Webb * @since 1.2.1 diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java index 6da0b0b9f928..bd75665736e6 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/builder/SpringApplicationBuilderTests.java @@ -100,8 +100,8 @@ public void propertiesAsProperties() { public void propertiesWithRepeatSeparator() { SpringApplicationBuilder application = new SpringApplicationBuilder() .sources(ExampleConfig.class).contextClass(StaticApplicationContext.class) - .properties("one=c:\\logging.file.name", "two=a:b", "three:c:\\logging.file.name", - "four:a:b"); + .properties("one=c:\\logging.file.name", "two=a:b", + "three:c:\\logging.file.name", "four:a:b"); this.context = application.run(); ConfigurableEnvironment environment = this.context.getEnvironment(); assertThat(environment.getProperty("one")).isEqualTo("c:\\logging.file.name"); 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 a533c4adb114..5b666c79f4aa 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 @@ -479,9 +479,10 @@ public void closingChildContextDoesNotCleanUpLoggingSystem() { @Test public void systemPropertiesAreSetForLoggingConfiguration() { TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, - "logging.exception-conversion-word=conversion", "logging.file.name=target/log", - "logging.path=path", "logging.pattern.console=console", - "logging.pattern.file=file", "logging.pattern.level=level"); + "logging.exception-conversion-word=conversion", + "logging.file.name=target/log", "logging.path=path", + "logging.pattern.console=console", "logging.pattern.file=file", + "logging.pattern.level=level"); this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); assertThat(System.getProperty(LoggingSystemProperties.CONSOLE_LOG_PATTERN)) From 1e783d601d68dc252ac33a0190f49a411913fc75 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Mon, 5 Nov 2018 16:42:38 -0500 Subject: [PATCH 04/13] Renamed logging.path to logging.file.path --- .../LogFileWebEndpointAutoConfiguration.java | 4 ++-- ...FileWebEndpointAutoConfigurationTests.java | 2 +- .../actuate/logging/LogFileWebEndpoint.java | 4 ++-- .../appendix-application-properties.adoc | 2 +- .../src/main/asciidoc/howto.adoc | 2 +- .../asciidoc/production-ready-features.adoc | 2 +- .../main/asciidoc/spring-boot-features.adoc | 6 +++--- .../logging/LoggingApplicationListener.java | 4 ++-- .../springframework/boot/logging/LogFile.java | 8 +++---- ...itional-spring-configuration-metadata.json | 21 +++++++++++++------ .../LoggingApplicationListenerTests.java | 4 ++-- .../boot/logging/LogFileTests.java | 2 +- 12 files changed, 35 insertions(+), 26 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java index 74917ef0a082..16776f376d4a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java @@ -66,10 +66,10 @@ public ConditionOutcome getMatchOutcome(ConditionContext context, return ConditionOutcome .match(message.found("logging.file.name").items(config)); } - config = environment.resolvePlaceholders("${logging.path:}"); + config = environment.resolvePlaceholders("${logging.file.path:}"); if (StringUtils.hasText(config)) { return ConditionOutcome - .match(message.found("logging.path").items(config)); + .match(message.found("logging.file.path").items(config)); } config = environment.getProperty("management.endpoint.logfile.external-file"); if (StringUtils.hasText(config)) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java index b8c8296d67b1..df94940de234 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java @@ -55,7 +55,7 @@ public void logFileWebEndpointIsAutoConfiguredWhenLoggingFileIsSet() { @Test public void logFileWebEndpointIsAutoConfiguredWhenLoggingPathIsSet() { - this.contextRunner.withPropertyValues("logging.path:test/logs").run( + this.contextRunner.withPropertyValues("logging.file.path:test/logs").run( (context) -> assertThat(context).hasSingleBean(LogFileWebEndpoint.class)); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LogFileWebEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LogFileWebEndpoint.java index 2d21bd9e5bed..3be400b783ea 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LogFileWebEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LogFileWebEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -70,7 +70,7 @@ private Resource getLogFileResource() { } LogFile logFile = LogFile.get(this.environment); if (logFile == null) { - logger.debug("Missing 'logging.file.name' or 'logging.path' properties"); + logger.debug("Missing 'logging.file.name' or 'logging.file.path' properties"); return null; } return new FileSystemResource(logFile.toString()); diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 854ddba8557c..da46f7f843f4 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -42,7 +42,7 @@ content into your application. Rather, pick only the properties that you need. logging.file.max-size=10MB # Maximum log file size. Only supported with the default logback setup. logging.group.*= # Log groups to quickly change multiple loggers at the same time. For instance, `logging.level.db=org.hibernate,org.springframework.jdbc`. logging.level.*= # Log levels severity mapping. For instance, `logging.level.org.springframework=DEBUG`. - logging.path= # Location of the log file. For instance, `/var/log`. + logging.file.path= # Location of the log file. For instance, `/var/log`. logging.pattern.console= # Appender pattern for output to the console. Supported only with the default Logback setup. logging.pattern.dateformat=yyyy-MM-dd HH:mm:ss.SSS # Appender pattern for log date format. Supported only with the default Logback setup. logging.pattern.file= # Appender pattern for output to a file. Supported only with the default Logback setup. diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc index cbdfeec98c9b..340879126cf9 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -1562,7 +1562,7 @@ some useful System properties that the `LoggingSystem` takes care of creating fo * `${PID}`: The current process ID. * `${LOG_FILE}`: Whether `logging.file.name` was set in Boot's external configuration. -* `${LOG_PATH}`: Whether `logging.path` (representing a directory for +* `${LOG_PATH}`: Whether `logging.file.path` (representing a directory for log files to live in) was set in Boot's external configuration. * `${LOG_EXCEPTION_CONVERSION_WORD}`: Whether `logging.exception-conversion-word` was set in Boot's external configuration. diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc index 8124d05724e5..2cabb33fb75b 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc @@ -164,7 +164,7 @@ use the following additional endpoints: |Yes |`logfile` -|Returns the contents of the logfile (if `logging.file.name` or `logging.path` properties have +|Returns the contents of the logfile (if `logging.file.name` or `logging.file.path` properties have been set). Supports the use of the HTTP `Range` header to retrieve part of the log file's content. |Yes diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index a8120c13a0b6..f1662bb58abc 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -1686,7 +1686,7 @@ The following colors and styles are supported: === File Output By default, Spring Boot logs only to the console and does not write log files. If you want to write log files in addition to the console output, you need to set a -`logging.file.name` or `logging.path` property (for example, in your +`logging.file.name` or `logging.file.path` property (for example, in your `application.properties`). The following table shows how the `logging.*` properties can be used together: @@ -1694,7 +1694,7 @@ The following table shows how the `logging.*` properties can be used together: .Logging properties [cols="1,1,1,4"] |=== -|`logging.file.name` |`logging.path` |Example |Description +|`logging.file.name` |`logging.file.path` |Example |Description |_(none)_ |_(none)_ @@ -1849,7 +1849,7 @@ setup.) |Maximum number of archive log files to keep (if LOG_FILE enabled). (Only supported with the default Logback setup.) -|`logging.path` +|`logging.file.path` |`LOG_PATH` |If defined, it is used in the default log configuration. diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java index b12f508a5943..d73aa95f803a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java @@ -68,8 +68,8 @@ * {@literal java -jar myapp.jar [--debug | --trace]}). If you prefer to ignore these * properties you can set {@link #setParseArgs(boolean) parseArgs} to {@code false}. *

- * By default, log output is only written to the console. If a log file is required the - * {@code logging.path} and {@code logging.file.name} properties can be used. + * By default, log output is only written to the console. If a log file is required, the + * {@code logging.file.path} and {@code logging.file.name} properties can be used. *

* Some system properties may be set as side effects, and these can be useful if the * logging configuration supports placeholders (i.e. log4j or logback): diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java index bcf68f4e09a2..5400ca8eb51b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java @@ -25,9 +25,9 @@ /** * A reference to a log output file. Log output files are specified using - * {@code logging.file.name} or {@code logging.path} {@link Environment} properties. If - * the {@code logging.file.name} property is not specified {@code "spring.log"} will be - * written in the {@code logging.path} directory. + * {@code logging.file.name} or {@code logging.file.path} {@link Environment} properties. + * If the {@code logging.file.name} property is not specified {@code "spring.log"} will be + * written in the {@code logging.file.path} directory. * * @author Phillip Webb * @since 1.2.1 @@ -45,7 +45,7 @@ public class LogFile { * The name of the Spring property that contains the directory where log files are * written. */ - public static final String PATH_PROPERTY = "logging.path"; + public static final String PATH_PROPERTY = "logging.file.path"; private final String file; diff --git a/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json index efaeef25b930..77bdb9e0d875 100644 --- a/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -83,6 +83,21 @@ "level": "error" } }, + { + "name": "logging.file.path", + "type": "java.lang.String", + "description": "Location of the log file. For instance, `/var/log`.", + "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener" + }, + { + "name": "logging.path", + "type": "java.lang.String", + "description": "Location of the log file. For instance, `/var/log`.", + "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener", + "deprecation": { + "replacement": "logging.file.path" + } + }, { "name": "logging.file.max-size", "type": "java.lang.String", @@ -109,12 +124,6 @@ "description": "Log levels severity mapping. For instance, `logging.level.org.springframework=DEBUG`.", "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener" }, - { - "name": "logging.path", - "type": "java.lang.String", - "description": "Location of the log file. For instance, `/var/log`.", - "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener" - }, { "name": "logging.pattern.console", "type": "java.lang.String", 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 5b666c79f4aa..65e5f301370a 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 @@ -240,7 +240,7 @@ public void addLogFilePropertyWithDefault() { public void addLogPathProperty() { TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "logging.config=classpath:logback-nondefault.xml", - "logging.path=target/foo/"); + "logging.file.path=target/foo/"); this.initializer.initialize(this.context.getEnvironment(), this.context.getClassLoader()); Log logger = LogFactory.getLog(LoggingApplicationListenerTests.class); @@ -480,7 +480,7 @@ public void closingChildContextDoesNotCleanUpLoggingSystem() { public void systemPropertiesAreSetForLoggingConfiguration() { TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "logging.exception-conversion-word=conversion", - "logging.file.name=target/log", "logging.path=path", + "logging.file.name=target/log", "logging.file.path=path", "logging.pattern.console=console", "logging.pattern.file=file", "logging.pattern.level=level"); this.initializer.initialize(this.context.getEnvironment(), 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 c5bc83d6423a..20bc83eb8716 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 @@ -85,7 +85,7 @@ public void loggingFileAndPath() { private PropertyResolver getPropertyResolver(String file, String path) { Map properties = new LinkedHashMap<>(); properties.put("logging.file.name", file); - properties.put("logging.path", path); + properties.put("logging.file.path", path); PropertySource propertySource = new MapPropertySource("properties", properties); MutablePropertySources propertySources = new MutablePropertySources(); From 3b5e914b728e964134dfae3d4031486be95fe7d4 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Mon, 5 Nov 2018 16:49:35 -0500 Subject: [PATCH 05/13] Support deprecated "logging.file" property --- .../META-INF/additional-spring-configuration-metadata.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 77bdb9e0d875..d40440c9d157 100644 --- a/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -79,8 +79,7 @@ "description": "Log file name (for instance, `myapp.log`). Names can be an exact location or relative to the current directory.", "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener", "deprecation": { - "replacement": "logging.file.name", - "level": "error" + "replacement": "logging.file.name" } }, { From 6742f1d5a7ac95bcf83cf5c377dd13b65b372ca5 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Fri, 9 Nov 2018 18:26:36 -0500 Subject: [PATCH 06/13] Moved deprecated properties at the bottom of the array --- ...itional-spring-configuration-metadata.json | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json index d40440c9d157..07d7560b40d4 100644 --- a/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -73,30 +73,12 @@ "description": "Log file name (for instance, `myapp.log`). Names can be an exact location or relative to the current directory.", "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener" }, - { - "name": "logging.file", - "type": "java.lang.String", - "description": "Log file name (for instance, `myapp.log`). Names can be an exact location or relative to the current directory.", - "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener", - "deprecation": { - "replacement": "logging.file.name" - } - }, { "name": "logging.file.path", "type": "java.lang.String", "description": "Location of the log file. For instance, `/var/log`.", "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener" }, - { - "name": "logging.path", - "type": "java.lang.String", - "description": "Location of the log file. For instance, `/var/log`.", - "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener", - "deprecation": { - "replacement": "logging.file.path" - } - }, { "name": "logging.file.max-size", "type": "java.lang.String", @@ -353,7 +335,25 @@ "level": "error", "reason": "Application context ids are now unique by default." } - } + }, + { + "name": "logging.file", + "type": "java.lang.String", + "description": "Log file name (for instance, `myapp.log`). Names can be an exact location or relative to the current directory.", + "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener", + "deprecation": { + "replacement": "logging.file.name" + } + }, + { + "name": "logging.path", + "type": "java.lang.String", + "description": "Location of the log file. For instance, `/var/log`.", + "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener", + "deprecation": { + "replacement": "logging.file.path" + } + }, ], "hints": [ { From 563b8ddb5ceba1bc94aec6910564dde8f20b0f77 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Fri, 9 Nov 2018 18:29:05 -0500 Subject: [PATCH 07/13] Uniformized order of deprecation properties --- .../META-INF/additional-spring-configuration-metadata.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 07d7560b40d4..4d7b2f517ffe 100644 --- a/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -332,8 +332,8 @@ "type": "java.lang.Integer", "description": "Application index.", "deprecation": { - "level": "error", - "reason": "Application context ids are now unique by default." + "reason": "Application context ids are now unique by default.", + "level": "error" } }, { From f755a5f94ba060eab2dc63174f1a7169db706dd4 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Sat, 10 Nov 2018 17:46:56 -0500 Subject: [PATCH 08/13] Minor fix --- .../META-INF/additional-spring-configuration-metadata.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 4d7b2f517ffe..9d757129bbd9 100644 --- a/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -353,7 +353,7 @@ "deprecation": { "replacement": "logging.file.path" } - }, + } ], "hints": [ { @@ -364,7 +364,6 @@ "parameters": { "group": false } - } ] }, From e2ef67f6384b4d38ef49398ddd9d1b1b21ff4d15 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Sat, 10 Nov 2018 17:52:45 -0500 Subject: [PATCH 09/13] Added default error level --- .../migrator/PropertiesMigrationReporter.java | 1 + .../additional-spring-configuration-metadata.json | 6 ++++-- .../springframework/boot/logging/LogFileTests.java | 12 ++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java index 4c90120c422c..90910521f279 100644 --- a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java +++ b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java @@ -88,6 +88,7 @@ private PropertySource mapPropertiesWithReplacement( properties.forEach((property) -> (isRenamed(property) ? renamed : unsupported) .add(property)); report.add(name, renamed, unsupported); + System.out.println("name="+name+"; renamed="+renamed); if (renamed.isEmpty()) { return null; } diff --git a/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 9d757129bbd9..56759ba416b0 100644 --- a/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -342,7 +342,8 @@ "description": "Log file name (for instance, `myapp.log`). Names can be an exact location or relative to the current directory.", "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener", "deprecation": { - "replacement": "logging.file.name" + "replacement": "logging.file.name", + "level": "error" } }, { @@ -351,7 +352,8 @@ "description": "Location of the log file. For instance, `/var/log`.", "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener", "deprecation": { - "replacement": "logging.file.path" + "replacement": "logging.file.path", + "level": "error" } } ], 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 20bc83eb8716..367d2c81f151 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 @@ -43,6 +43,18 @@ public void noProperties() { LogFile logFile = LogFile.get(resolver); assertThat(logFile).isNull(); } + + @Test + public void deprecatedLoggingFile() { + PropertyResolver resolver = getPropertyResolver("log.file", null); + LogFile logFile = LogFile.get(resolver); + 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)).isNull(); + } @Test public void loggingFile() { From b8f5e398d747fa9cb31edee1beb62039f5e8d7e1 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Sat, 10 Nov 2018 19:23:47 -0500 Subject: [PATCH 10/13] Support deprecated properties file directly in LogFile Also added tests for said change --- .../logging/LogFileWebEndpointTests.java | 10 ++++ .../migrator/PropertiesMigrationReporter.java | 1 - .../springframework/boot/logging/LogFile.java | 21 ++++++++ .../LoggingApplicationListenerTests.java | 24 +++++++++ .../boot/logging/LogFileTests.java | 53 +++++++++++++++++-- 5 files changed, 104 insertions(+), 5 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointTests.java index 6df25e6daa26..fd008fc1fafe 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LogFileWebEndpointTests.java @@ -76,6 +76,16 @@ public void resourceResponseWithLogFile() throws Exception { StandardCharsets.UTF_8)).isEqualTo("--TEST--"); } + @Test + @Deprecated + public void resourceResponseWithLogFileAndDeprecatedProperty() throws Exception { + this.environment.setProperty("logging.file", this.logFile.getAbsolutePath()); + Resource resource = this.endpoint.logFile(); + assertThat(resource).isNotNull(); + assertThat(StreamUtils.copyToString(resource.getInputStream(), + StandardCharsets.UTF_8)).isEqualTo("--TEST--"); + } + @Test public void resourceResponseWithExternalLogFile() throws Exception { LogFileWebEndpoint endpoint = new LogFileWebEndpoint(this.environment, diff --git a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java index 90910521f279..4c90120c422c 100644 --- a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java +++ b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java @@ -88,7 +88,6 @@ private PropertySource mapPropertiesWithReplacement( properties.forEach((property) -> (isRenamed(property) ? renamed : unsupported) .add(property)); report.add(name, renamed, unsupported); - System.out.println("name="+name+"; renamed="+renamed); if (renamed.isEmpty()) { return null; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java index 5400ca8eb51b..c60d0402fd41 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java @@ -47,6 +47,20 @@ public class LogFile { */ public static final String PATH_PROPERTY = "logging.file.path"; + /** + * The name of the Spring property that contains the name of the log file. Names can + * be an exact location or relative to the current directory. + */ + @Deprecated + public static final String DEPRECATED_FILE_PROPERTY = "logging.file"; + + /** + * The name of the Spring property that contains the directory where log files are + * written. + */ + @Deprecated + public static final String DEPRECATED_PATH_PROPERTY = "logging.path"; + private final String file; private final String path; @@ -83,6 +97,7 @@ public void applyToSystemProperties() { * @param properties the properties to apply to */ public void applyTo(Properties properties) { + System.out.println("[LogFile][applyTo]"); put(properties, LoggingSystemProperties.LOG_PATH, this.path); put(properties, LoggingSystemProperties.LOG_FILE, toString()); } @@ -115,6 +130,12 @@ public String toString() { public static LogFile get(PropertyResolver propertyResolver) { String file = propertyResolver.getProperty(FILE_PROPERTY); String path = propertyResolver.getProperty(PATH_PROPERTY); + if (file == null) { + file = propertyResolver.getProperty(DEPRECATED_FILE_PROPERTY); + } + if (path == null) { + path = propertyResolver.getProperty(DEPRECATED_PATH_PROPERTY); + } if (StringUtils.hasLength(file) || StringUtils.hasLength(path)) { return new LogFile(file, path); } 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 65e5f301370a..97b1fc4a3fa2 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 @@ -500,6 +500,30 @@ public void systemPropertiesAreSetForLoggingConfiguration() { assertThat(System.getProperty(LoggingSystemProperties.PID_KEY)).isNotNull(); } + @Test + @Deprecated + public void systemPropertiesAreSetForLoggingConfigurationWithDeprecatedProperties() { + TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, + "logging.exception-conversion-word=conversion", "logging.file=target/log", + "logging.path=path", "logging.pattern.console=console", + "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.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.PID_KEY)).isNotNull(); + } + @Test public void environmentPropertiesIgnoreUnresolvablePlaceholders() { // gh-7719 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 367d2c81f151..197fe0d5ca71 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 @@ -43,9 +43,9 @@ public void noProperties() { LogFile logFile = LogFile.get(resolver); assertThat(logFile).isNull(); } - + @Test - public void deprecatedLoggingFile() { + public void loggingFile() { PropertyResolver resolver = getPropertyResolver("log.file", null); LogFile logFile = LogFile.get(resolver); Properties properties = new Properties(); @@ -57,8 +57,10 @@ public void deprecatedLoggingFile() { } @Test - public void loggingFile() { - PropertyResolver resolver = getPropertyResolver("log.file", null); + @Deprecated + public void loggingFileWithDeprecatedProperties() { + PropertyResolver resolver = getPropertyResolverWithDeprecatedProperties( + "log.file", null); LogFile logFile = LogFile.get(resolver); Properties properties = new Properties(); logFile.applyTo(properties); @@ -81,6 +83,21 @@ public void loggingPath() { .isEqualTo("logpath"); } + @Test + @Deprecated + public void loggingPathWithDeprecatedProperties() { + PropertyResolver resolver = getPropertyResolverWithDeprecatedProperties(null, + "logpath"); + LogFile logFile = LogFile.get(resolver); + 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"); + } + @Test public void loggingFileAndPath() { PropertyResolver resolver = getPropertyResolver("log.file", "logpath"); @@ -94,6 +111,21 @@ public void loggingFileAndPath() { .isEqualTo("logpath"); } + @Test + @Deprecated + public void loggingFileAndPathWithDeprecatedProperties() { + PropertyResolver resolver = getPropertyResolverWithDeprecatedProperties( + "log.file", "logpath"); + LogFile logFile = LogFile.get(resolver); + 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"); + } + private PropertyResolver getPropertyResolver(String file, String path) { Map properties = new LinkedHashMap<>(); properties.put("logging.file.name", file); @@ -105,4 +137,17 @@ private PropertyResolver getPropertyResolver(String file, String path) { return new PropertySourcesPropertyResolver(propertySources); } + @Deprecated + private PropertyResolver getPropertyResolverWithDeprecatedProperties(String file, + String path) { + Map properties = new LinkedHashMap<>(); + properties.put("logging.file", file); + properties.put("logging.path", path); + PropertySource propertySource = new MapPropertySource("properties", + properties); + MutablePropertySources propertySources = new MutablePropertySources(); + propertySources.addFirst(propertySource); + return new PropertySourcesPropertyResolver(propertySources); + } + } From b23788595594f2384580b748ee6a8a82e4e9865b Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Sat, 10 Nov 2018 19:35:49 -0500 Subject: [PATCH 11/13] Clean up --- .../src/main/java/org/springframework/boot/logging/LogFile.java | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java index c60d0402fd41..983598507188 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java @@ -97,7 +97,6 @@ public void applyToSystemProperties() { * @param properties the properties to apply to */ public void applyTo(Properties properties) { - System.out.println("[LogFile][applyTo]"); put(properties, LoggingSystemProperties.LOG_PATH, this.path); put(properties, LoggingSystemProperties.LOG_FILE, toString()); } From 0d583f13fdd314237fa5ec2627a17f9b6f2974e0 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Tue, 13 Nov 2018 17:28:43 -0500 Subject: [PATCH 12/13] Check deprecated logging property if non-deprecated are properties resolve to empty string --- .../LogFileWebEndpointAutoConfiguration.java | 21 ++++++++++++++----- ...FileWebEndpointAutoConfigurationTests.java | 15 +++++++++++++ .../springframework/boot/logging/LogFile.java | 1 + 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java index 16776f376d4a..b6f42a0876d8 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -23,6 +23,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.SpringBootCondition; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.logging.LogFile; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; @@ -35,6 +36,7 @@ * {@link EnableAutoConfiguration Auto-configuration} for {@link LogFileWebEndpoint}. * * @author Andy Wilkinson + * @author Christian Carriere-Tisseur * @since 2.0.0 */ @Configuration @@ -60,16 +62,25 @@ private static class LogFileCondition extends SpringBootCondition { public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { Environment environment = context.getEnvironment(); - String config = environment.resolvePlaceholders("${logging.file.name:}"); + String config = environment + .resolvePlaceholders("${" + LogFile.FILE_PROPERTY + ":}"); + if (!StringUtils.hasText(config)) { + config = environment.resolvePlaceholders( + "${" + LogFile.DEPRECATED_FILE_PROPERTY + ":}"); + } ConditionMessage.Builder message = ConditionMessage.forCondition("Log File"); if (StringUtils.hasText(config)) { return ConditionOutcome - .match(message.found("logging.file.name").items(config)); + .match(message.found(LogFile.FILE_PROPERTY).items(config)); + } + config = environment.resolvePlaceholders("${" + LogFile.PATH_PROPERTY + ":}"); + if (!StringUtils.hasText(config)) { + config = environment.resolvePlaceholders( + "${" + LogFile.DEPRECATED_PATH_PROPERTY + ":}"); } - config = environment.resolvePlaceholders("${logging.file.path:}"); if (StringUtils.hasText(config)) { return ConditionOutcome - .match(message.found("logging.file.path").items(config)); + .match(message.found(LogFile.PATH_PROPERTY).items(config)); } config = environment.getProperty("management.endpoint.logfile.external-file"); if (StringUtils.hasText(config)) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java index df94940de234..c36cb90104fe 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java @@ -38,6 +38,7 @@ * @author Andy Wilkinson * @author Stephane Nicoll * @author Phillip Webb + * @author Christian Carriere-Tisseur */ public class LogFileWebEndpointAutoConfigurationTests { @@ -53,12 +54,26 @@ public void logFileWebEndpointIsAutoConfiguredWhenLoggingFileIsSet() { (context) -> assertThat(context).hasSingleBean(LogFileWebEndpoint.class)); } + @Test + @Deprecated + public void logFileWebEndpointIsAutoConfiguredWhenLoggingFileIsSetWithDeprecatedProperty() { + this.contextRunner.withPropertyValues("logging.file:test.log").run( + (context) -> assertThat(context).hasSingleBean(LogFileWebEndpoint.class)); + } + @Test public void logFileWebEndpointIsAutoConfiguredWhenLoggingPathIsSet() { this.contextRunner.withPropertyValues("logging.file.path:test/logs").run( (context) -> assertThat(context).hasSingleBean(LogFileWebEndpoint.class)); } + @Test + @Deprecated + public void logFileWebEndpointIsAutoConfiguredWhenLoggingPathIsSetWithDeprecatedProperty() { + this.contextRunner.withPropertyValues("logging.path:test/logs").run( + (context) -> assertThat(context).hasSingleBean(LogFileWebEndpoint.class)); + } + @Test public void logFileWebEndpointIsAutoConfiguredWhenExternalFileIsSet() { this.contextRunner diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java index 983598507188..ea6120816e6f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java @@ -30,6 +30,7 @@ * written in the {@code logging.file.path} directory. * * @author Phillip Webb + * @author Christian Carriere-Tisseur * @since 1.2.1 * @see #get(PropertyResolver) */ From ba1cad8ba8d40259bfd23e34b416ad0db4b39aef Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Wed, 14 Nov 2018 20:38:23 -0500 Subject: [PATCH 13/13] Renamed DEPRECATED_*_PROPERTY to FILE_PROPERTY and FILE_PROPERTY to FILE_*_PROPERTY --- .../LogFileWebEndpointAutoConfiguration.java | 17 ++++++------- .../springframework/boot/logging/LogFile.java | 24 +++++++++++-------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java index b6f42a0876d8..dbb2c6326eed 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java @@ -63,24 +63,25 @@ public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { Environment environment = context.getEnvironment(); String config = environment - .resolvePlaceholders("${" + LogFile.FILE_PROPERTY + ":}"); + .resolvePlaceholders("${" + LogFile.FILE_NAME_PROPERTY + ":}"); if (!StringUtils.hasText(config)) { - config = environment.resolvePlaceholders( - "${" + LogFile.DEPRECATED_FILE_PROPERTY + ":}"); + config = environment + .resolvePlaceholders("${" + LogFile.FILE_PROPERTY + ":}"); } ConditionMessage.Builder message = ConditionMessage.forCondition("Log File"); if (StringUtils.hasText(config)) { return ConditionOutcome - .match(message.found(LogFile.FILE_PROPERTY).items(config)); + .match(message.found(LogFile.FILE_NAME_PROPERTY).items(config)); } - config = environment.resolvePlaceholders("${" + LogFile.PATH_PROPERTY + ":}"); + config = environment + .resolvePlaceholders("${" + LogFile.FILE_PATH_PROPERTY + ":}"); if (!StringUtils.hasText(config)) { - config = environment.resolvePlaceholders( - "${" + LogFile.DEPRECATED_PATH_PROPERTY + ":}"); + config = environment + .resolvePlaceholders("${" + LogFile.PATH_PROPERTY + ":}"); } if (StringUtils.hasText(config)) { return ConditionOutcome - .match(message.found(LogFile.PATH_PROPERTY).items(config)); + .match(message.found(LogFile.FILE_PATH_PROPERTY).items(config)); } config = environment.getProperty("management.endpoint.logfile.external-file"); if (StringUtils.hasText(config)) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java index ea6120816e6f..e5f341741a90 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java @@ -39,28 +39,32 @@ public class LogFile { /** * The name of the Spring property that contains the name of the log file. Names can * be an exact location or relative to the current directory. + * @deprecated since 2.2.0 in favor of {@link #FILE_NAME_PROPERTY} */ - public static final String FILE_PROPERTY = "logging.file.name"; + @Deprecated + public static final String FILE_PROPERTY = "logging.file"; /** * The name of the Spring property that contains the directory where log files are * written. + * @deprecated since 2.2.0 in favor of {@link #FILE_PATH_PROPERTY} */ - public static final String PATH_PROPERTY = "logging.file.path"; + @Deprecated + public static final String PATH_PROPERTY = "logging.path"; /** * The name of the Spring property that contains the name of the log file. Names can * be an exact location or relative to the current directory. + * @since 2.2.0 */ - @Deprecated - public static final String DEPRECATED_FILE_PROPERTY = "logging.file"; + public static final String FILE_NAME_PROPERTY = "logging.file.name"; /** * The name of the Spring property that contains the directory where log files are * written. + * @since 2.2.0 */ - @Deprecated - public static final String DEPRECATED_PATH_PROPERTY = "logging.path"; + public static final String FILE_PATH_PROPERTY = "logging.file.path"; private final String file; @@ -128,13 +132,13 @@ public String toString() { * suitable properties */ public static LogFile get(PropertyResolver propertyResolver) { - String file = propertyResolver.getProperty(FILE_PROPERTY); - String path = propertyResolver.getProperty(PATH_PROPERTY); + String file = propertyResolver.getProperty(FILE_NAME_PROPERTY); + String path = propertyResolver.getProperty(FILE_PATH_PROPERTY); if (file == null) { - file = propertyResolver.getProperty(DEPRECATED_FILE_PROPERTY); + file = propertyResolver.getProperty(FILE_PROPERTY); } if (path == null) { - path = propertyResolver.getProperty(DEPRECATED_PATH_PROPERTY); + path = propertyResolver.getProperty(PATH_PROPERTY); } if (StringUtils.hasLength(file) || StringUtils.hasLength(path)) { return new LogFile(file, path);