Log file location should be evaluated just once
Using a random value for the logfile name caused the logfile endpoint to return a 404 as the name was resolved from the environment on every request. This commit registers a bean for LogFile which is then used by the logfile endpoint. Fixes gh-17434
This commit is contained in:
@@ -66,6 +66,13 @@ public class EndpointsPropertiesSampleActuatorApplicationTests {
|
||||
assertThat(entity.getBody()).contains("\"hello\":\"world\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void logfileWithRandomName() {
|
||||
ResponseEntity<String> entity = this.restTemplate.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/admin/logfile", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
}
|
||||
|
||||
private String getPassword() {
|
||||
return "password";
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
server.error.path: /oops
|
||||
management.endpoint.health.show-details: always
|
||||
management.endpoints.web.base-path: /admin
|
||||
logging.file=./target/${spring.application.instance_id}.log
|
||||
spring.application.instance_id=${random.value}
|
||||
|
||||
Reference in New Issue
Block a user