當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
Spring Boot –使用执行器端点在运行时配置日志级别
生活随笔
收集整理的這篇文章主要介紹了
Spring Boot –使用执行器端点在运行时配置日志级别
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
從Spring Boot 1.5開始,新的loggers器執行器端點允許在運行時查看和更改應用程序記錄級別。
- 將spring-boot-actuator添加到您的項目
- 禁用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
總結
以上是生活随笔為你收集整理的Spring Boot –使用执行器端点在运行时配置日志级别的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: rsync 同步优化_可以优化同步吗?
- 下一篇: 使用Arquillian测试Spring