Java Spring引导中的日志文件端点

Java Spring引导中的日志文件端点,java,spring,spring-boot,Java,Spring,Spring Boot,我读了Spring Boot Actuator,看到了这里提到的logfileendpoint,这真的很方便 但是,该端点未在我的应用程序中注册,我不知道如何使其可用。这里需要什么 要启用此功能,需要设置以下两个参数之一: logging.file.name logging.file.path 在此之后,默认情况下应启用端点。/logfile包含在版本中 如果您使用的是早期版本,那么它将不存在。我在下面添加了启用/logfile端点的代码 pom.xml -----------

我读了Spring Boot Actuator,看到了这里提到的
logfile
endpoint,这真的很方便


但是,该端点未在我的应用程序中注册,我不知道如何使其可用。这里需要什么

要启用此功能,需要设置以下两个参数之一:

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


在此之后,默认情况下应启用端点。

/logfile
包含在版本中


如果您使用的是早期版本,那么它将不存在。

我在下面添加了启用/logfile端点的代码

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
pom.xml
-----------
org.springframework.boot
弹簧靴起动器执行器
应用程序属性
-----------------------
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

我的application.properties中有以下几行。我使用带执行器的弹簧靴

logging.file.name=./logs/log-file.log
management.endpoints.web.exposure.include=*
如果没有管理分机线,反应是

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
我在下面用了好几年了

版本2.1.3->management.endpoint.logfile=C:/apps/Benefits logs/adapt-rest.log 如您所见,classLogFileWebEndpointProperties

这也行得通 logging.file=C:/apps/Benefits logs/adapt-rest.log


无需添加logging.path。如果您看到LogFileCondition类,您就会知道。

看起来它们是内置的。你不能只点击/log文件或/health?我在文档中看到了这一点,但是我也没能让它起作用。我已经在1.2.5.RELEASE到1.3.0.M5中进行了尝试。你有什么提示吗?你自己试过并观察到它工作了吗?我们已经在多个应用程序中使用过它,但我们大约在9个月前设置了这些应用程序,我不记得有任何问题。也许你应该开始在这篇文章中添加一些代码和pom.xml等。仅供参考,我在Spring Boot/logfile端点上下了赌注,并编写了我自己的,命名为'/logFile',所以它不会发生冲突,以防有一天我让/logFile工作。这可能是正确的答案。有关spring创建MVC端点的条件,请参阅。