Fix LogFile conditions to check for exposure as well

Closes gh-16298
This commit is contained in:
Valery_Yalauchuk 2019-03-23 19:52:22 +03:00 committed by Stephane Nicoll
parent 76ca467d92
commit c880e10c41
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();