Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/actuator/logfile endpoint returning 404 when logging.file property contains a random value #17434

Closed
morth opened this issue Jul 5, 2019 · 3 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@morth
Copy link

morth commented Jul 5, 2019

I'm running a Spring Boot 2.1.6.RELEASE application using spring-boot-starter-actuator to expose the application's logfile over HTTP. My application.properties looks as follows (runnable example here):

spring.application.name=actuator-test
spring.application.instance_id=${random.value}

management.endpoints.web.exposure.include=*

logging.file=./target/logs/${spring.application.name}/${spring.application.instance_id}.log

When I run the application and call up http://localhost:8080/actuator/logfile I get a 404 error, even though the endpoint is listed in http://localhost:8080/actuator:

{
  "_links": {
    "self": {
      "href": "http://localhost:8080/actuator",
      "templated": false
    },
    ...
    "logfile": {
      "href": "http://localhost:8080/actuator/logfile",
      "templated": false
    },
    ...
  }
}

The logfile itself is successfully generated and stored in the expected path.

I've found out that this has something to do with the use of placeholders in the logging.file property definition. As soon as I replace logging.file=./target/logs/${spring.application.name}/${spring.application.instance_id}.log with something like logging.file=./target/logs/test.log, everything works as expected.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 5, 2019
@philwebb philwebb added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 5, 2019
@philwebb philwebb added this to the 2.1.x milestone Jul 5, 2019
@morth
Copy link
Author

morth commented Jul 5, 2019

Further investigation showed that this has more to do with the use of a random value in the logfile name than with the use of placeholders.

Working:

spring.application.name=actuator-test
spring.application.instance_id=foo
management.endpoints.web.exposure.include=*
logging.file=./target/logs/${spring.application.name}/${spring.application.instance_id}.log

Not working:

spring.application.name=actuator-test
spring.application.instance_id=${random.value}        # or ${random.uuid} or ${random.int}
management.endpoints.web.exposure.include=*
logging.file=./target/logs/${spring.application.name}/${spring.application.instance_id}.log

or

management.endpoints.web.exposure.include=*
logging.file=./target/logs/${random.int}.log

@morth morth changed the title /actuator/logfile endpoint returning 404 when logging.file property contains a placeholder /actuator/logfile endpoint returning 404 when logging.file property contains a random value Jul 5, 2019
@morth
Copy link
Author

morth commented Jul 5, 2019

The reason for this is that the ${random.value} expression is re-evaluated every time that http://localhost:8080/actuator/logfile is called.

It's evaluated first on application startup (determining the logfile name on the file system). Every time the endpoint is accessed and tries to resolve the logfile name in LogFileWebEndpoint.getLogFileResource() a new random value is generated, thus the logfile cannot be found.

@mxoop

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

5 participants