简体   繁体   English

春季启动。错过/日志文件端点

[英]Spring Boot. Missed /logfile endpoint

I have a problem with logfile endpoint in my spring boot application - it's missed. 我在Spring启动应用程序中遇到logfile端点问题 - 它已经错过了。 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 . 弹簧启动器启动器执行器版本为1.5.2 Also /info and /health endpoints works well for example. 另外/info/health端点也可以很好地工作。

Do you get an 404 (not found) or 401 (unauthorized)? 你有404(未找到)或401(未经授权)吗? 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". 否则,您可以通过将级别设置为DEBUG并搜索“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. 如果您未经授权使用401,请先阅读本文档

By default all sensitive HTTP endpoints are secured such that only users that have an ACTUATOR role may access them. 默认情况下,所有敏感HTTP端点都是安全的,这样只有具有ACTUATOR角色的用户才能访问它们。 Security is enforced using the standard HttpServletRequest.isUserInRole method. 使用标准HttpServletRequest.isUserInRole方法强制执行安全性。

[Tip] Use the management.security.roles property if you want something different to ACTUATOR. [Tip]如果你想要与ACTUATOR不同的东西,请使用management.security.roles属性。

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: 您可以通过更改management.security.enabled属性来执行此操作:

application.properties. application.properties。

management.security.enabled=false 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: 如果得到的是404,请确保在application.properties中添加logging.file或logging.path属性,如Endpoints (logfile)文档中所述:

Returns the contents of the logfile ( if logging.file or logging.path properties have been set ). 返回日志文件的内容( 如果已设置logging.file或logging.path属性 )。 Supports the use of the HTTP Range header to retrieve part of the log file's content. 支持使用HTTP Range标头来检索部分日志文件的内容。

I don't understand why the accepted answer worked, but for most cases, this is the reason why logfile endpoint gives a 404 response. 我不明白为什么接受的答案有效,但在大多数情况下,这就是logfile端点给出404响应的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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