SpringBoot Actuator日志文件端点返回404



调用GET/actuator/lofile返回404错误。

如何通过执行器/日志文件获取日志?

$ curl -XGET localhost:8001/actuator/logfile -i
HTTP/1.1 404 
Content-Length: 0
Date: Tue, 22 Sep 2020 08:43:44 GMT

我有下面的配置。

我用"本地"配置文件启动了应用程序。

我在日志文件夹中有日志文件(例如api_log.200-09-22-0.log(。

application.yml

management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: always
logging:
file:
path: log

logback-spring.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="log/console.xml"/>
<include resource="log/file.xml"/>
<root level="info">
<springProfile name="dev">
<appender-ref ref="dailyRollingFileAppender"/>
</springProfile>
<springProfile name="local">
<appender-ref ref="dailyRollingFileAppender"/>
</springProfile>
</root>
</configuration>

log/file.xml

<?xml version="1.0" encoding="UTF-8"?>
<appender name="dailyRollingFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/api_log.%d{yyyy-MM-dd}-%i.log</fileNamePattern>
<maxHistory>10</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>

/执行器/日志文件端点启用。

curl -XGET localhost:8001/actuator           
{
"_links": {
"self": {
"href": "http://localhost:8001/actuator",
"templated": false
},
"beans": {
"href": "http://localhost:8001/actuator/beans",
"templated": false
},
"caches": {
"href": "http://localhost:8001/actuator/caches",
"templated": false
},
"caches-cache": {
"href": "http://localhost:8001/actuator/caches/{cache}",
"templated": true
},
"health-path": {
"href": "http://localhost:8001/actuator/health/{*path}",
"templated": true
},
"health": {
"href": "http://localhost:8001/actuator/health",
"templated": false
},
"info": {
"href": "http://localhost:8001/actuator/info",
"templated": false
},
"conditions": {
"href": "http://localhost:8001/actuator/conditions",
"templated": false
},
"configprops": {
"href": "http://localhost:8001/actuator/configprops",
"templated": false
},
"env-toMatch": {
"href": "http://localhost:8001/actuator/env/{toMatch}",
"templated": true
},
"env": {
"href": "http://localhost:8001/actuator/env",
"templated": false
},
"logfile": {
"href": "http://localhost:8001/actuator/logfile",
"templated": false
},
"loggers-name": {
"href": "http://localhost:8001/actuator/loggers/{name}",
"templated": true
},
"loggers": {
"href": "http://localhost:8001/actuator/loggers",
"templated": false
},
"heapdump": {
"href": "http://localhost:8001/actuator/heapdump",
"templated": false
},
"threaddump": {
"href": "http://localhost:8001/actuator/threaddump",
"templated": false
},
"metrics": {
"href": "http://localhost:8001/actuator/metrics",
"templated": false
},
"metrics-requiredMetricName": {
"href": "http://localhost:8001/actuator/metrics/{requiredMetricName}",
"templated": true
},
"scheduledtasks": {
"href": "http://localhost:8001/actuator/scheduledtasks",
"templated": false
},
"mappings": {
"href": "http://localhost:8001/actuator/mappings",
"templated": false
}
}
}

更新application.yml

logging:
file:
path: log

logging:
path: log

最新更新