Merge pull request #16298 from yalov4uk

* pr/16298:
  Fix LogFile conditions to check for exposure as well
This commit is contained in:
Stephane Nicoll
2019-03-25 11:34:57 +01:00
2 changed files with 11 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
package org.springframework.boot.actuate.autoconfigure.logging;
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnExposedEndpoint;
import org.springframework.boot.actuate.logging.LogFileWebEndpoint;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
@@ -42,6 +43,7 @@ import org.springframework.util.StringUtils;
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnEnabledEndpoint(endpoint = LogFileWebEndpoint.class)
@ConditionalOnExposedEndpoint(endpoint = LogFileWebEndpoint.class)
@EnableConfigurationProperties(LogFileWebEndpointProperties.class)
public class LogFileWebEndpointAutoConfiguration {

View File

@@ -92,6 +92,15 @@ public class LogFileWebEndpointAutoConfigurationTests {
.doesNotHaveBean(LogFileWebEndpoint.class));
}
@Test
public void logFileWebEndpointCanBeExcluded() {
this.contextRunner
.withPropertyValues("logging.file.name:test.log",
"management.endpoints.web.exposure.exclude=logfile")
.run((context) -> assertThat(context)
.doesNotHaveBean(LogFileWebEndpoint.class));
}
@Test
public void logFileWebEndpointUsesConfiguredExternalFile() throws IOException {
File file = this.temp.newFile();