ps-aux
ps-aux

Reputation: 12174

logfile endpoint in Spring Boot

I read Spring Boot Actuator documentation and saw logfile endpoint mentioned there which would really come in handy.

However this endpoint is not registered in my app and I have no idea how to make it available. What is needed here?

Upvotes: 14

Views: 24015

Answers (6)

Yves-Marie L.
Yves-Marie L.

Reputation: 95

I'm using Spring Boot 2.7.5 and using the config server.

Although I noticed that logging.file.name works when the application.properties is embedded in the project, it didn't work when configured in the config server.

I had to use this property:

management.endpoint.logfile.external-file=${logging.file.name}

Upvotes: 0

Gergely Bacso
Gergely Bacso

Reputation: 14661

In order to enable this feature, one of these two params need to be set:

  • logging.file.name
  • logging.file.path

Logging configuration

After that the endpoint should be enabled by default.

Upvotes: 21

lekant
lekant

Reputation: 1002

/logfile was included in version 1.3.0+ only.

If you use an earlier version it will then not be present..

Upvotes: 3

user3283865
user3283865

Reputation: 1

I had used below for

version 2.1.3 -> management.endpoint.logfile=C:/apps/Benefits-logs/adapt-rest.log as you can see class LogFileWebEndpointProperties

and this also works logging.file=C:/apps/Benefits-logs/adapt-rest.log

No need to add logging.path. If you see LogFileCondition class you will get to know.

Upvotes: 0

Allahbaksh Asadullah
Allahbaksh Asadullah

Reputation: 696

I had below lines in my application.properties . I am using spring-boot with actuator

logging.file.name=./logs/log-file.log
management.endpoints.web.exposure.include=*

Without the management extension line, the response was

Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback.

Wed Dec 04 05:04:40 IST 2019 There was an unexpected error (type=Not Found, status=404). No message available

Upvotes: 0

Jan69
Jan69

Reputation: 1139

I added below code to enable /logfile endpoint

pom.xml
-----------

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>


application.properties
-----------------------

management.security.enabled=false
endpoints.env.enabled=false
endpoints.configprops.enabled=false
endpoints.autoconfig.enabled=false
endpoints.beans.enabled=false
endpoints.dump.enabled=true
endpoints.heapdump.enabled=true
logging.level.root=info
logging.file=target/app.log

Upvotes: 1

Related Questions