免费网站入口2022伊园,内部网页制作,中国电影家协会成员,望野古诗诵读从Spring Boot 1.5开始#xff0c;新的loggers器执行器端点允许在运行时查看和更改应用程序记录级别。 将spring-boot-actuator添加到您的项目 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-actuator新的loggers器执行器端点允许在运行时查看和更改应用程序记录级别。 将spring-boot-actuator添加到您的项目 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-actuator/artifactId
/dependency 禁用loggers或所有端点的安全性 将management.security.enabled设置为false或将endpoints.loggers.sensitive为false可禁用安全性。 请注意后者仅更改loggers端点。 获取所有记录器的详细信息 在浏览器中或使用curl执行/loggers端点。 您将获得记录器配置的详细视图例如片段 {levels: [OFF,ERROR,WARN,INFO,DEBUG,TRACE],loggers: {ROOT: {configuredLevel: TRACE,effectiveLevel: TRACE},org: {configuredLevel: null,effectiveLevel: TRACE},pl.codeleak.demos.sbt: {configuredLevel: null,effectiveLevel: TRACE},pl.codeleak.demos.sbt.Application: {configuredLevel: null,effectiveLevel: TRACE}}
} 获取选定的记录器详细信息 使用以下端点来获取所选记录器的详细信息 /logger/{logger} 例子 λ curl -i http://localhost:8080/loggers/ROOT{
configuredLevel: null,
effectiveLevel: TRACE
}λ curl -i http://localhost:8080/loggers/pl.codeleak.demos{
configuredLevel: null,
effectiveLevel: TRACE
} 在运行时更新选定的记录器级别 执行POST请求 curl -i -X POST -H Content-Type: application/json -d {configuredLevel: TRACE} http://localhost:8080/loggers/ROOT源代码 可以在https://github.com/kolorobot/spring-boot-thymeleaf存储库中找到示例配置。 翻译自: https://www.javacodegeeks.com/2017/03/spring-boot-configure-log-level-runtime-using-actuator-endpoint.html