Merge pull request #16298 from yalov4uk
* pr/16298: Fix LogFile conditions to check for exposure as well
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user