简体   繁体   中英

Spring Boot. Missed /logfile endpoint

I have a problem with logfile endpoint in my spring boot application - it's missed. This is my application config:

server:
  port: 8081

info:
  app:
    name: Foo Service
    component: Foo Service

secret-message: "{cipher}a702d2b5b0c6bc2db67e7d487c6142e7c23254108503d1856ff516d0a64bbd3663a2514a86647dcf8467d042abcb8a6e"

logging:
  file: "target/foo.log"

management:
  context-path: "/actuator"

spring:
  application:
    name: "foo-service"
  boot:
    admin:
      url: http://spring-boot-admin-url:9000
      client:
        health-url: http://app-url:8081/actuator/health
        management-url: http://app-url:8081/actuator
        service-url: http://app-url:8081
        metadata:
          user.name: "${security.user.name}"
          user.password:  "${security.user.password}"
      username: "${security.user.name}"
      password: "${security.user.password}"

security:
  user:
    name: name
    password: password

Spring boot starter actuator version is 1.5.2 . Also /info and /health endpoints works well for example.

Do you get an 404 (not found) or 401 (unauthorized)? If the latter is the case, add

endpoints:
   logfile:
      sensitive: false

Otherwise you may enable the autoconfiguration logging by setting the level to DEBUG and search for "logfile". This may give you some hints if and why the endpoint might not has been enabled.

logging.level.org.springframework.boot.autoconfigure.logging=DEBUG

If you get 401 unauthorized, please read this document first.

By default all sensitive HTTP endpoints are secured such that only users that have an ACTUATOR role may access them. Security is enforced using the standard HttpServletRequest.isUserInRole method.

[Tip] Use the management.security.roles property if you want something different to ACTUATOR.

If you are deploying applications behind a firewall, you may prefer that all your actuator endpoints can be accessed without requiring authentication. You can do this by changing the management.security.enabled property:

application.properties.

management.security.enabled=false

If what you get is a 404, make sure to add logging.file or logging.path property in application.properties, as stated in Endpoints (logfile) documentation:

Returns the contents of the logfile ( if logging.file or logging.path properties have been set ). Supports the use of the HTTP Range header to retrieve part of the log file's content.

I don't understand why the accepted answer worked, but for most cases, this is the reason why logfile endpoint gives a 404 response.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM