Fix LogFile conditions to check for exposure as well
Closes gh-16298
This commit is contained in:
parent
76ca467d92
commit
c880e10c41
|
|
@ -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 {
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue