記錄 HTTP 交換

你可以透過在應用配置中提供一個型別為 HttpExchangeRepository 的 Bean 來啟用 HTTP 交換的記錄。為了方便,Spring Boot 提供了 InMemoryHttpExchangeRepository,它預設儲存最近 100 個請求-響應交換。InMemoryHttpExchangeRepository 與追蹤解決方案相比,有限,我們建議僅將其用於開發環境。對於生產環境,我們建議使用生產就緒的追蹤或可觀測性解決方案,例如 Zipkin 或 OpenTelemetry。或者,你可以建立自己的 HttpExchangeRepository

你可以使用 httpexchanges 端點獲取儲存在 HttpExchangeRepository 中的請求-響應交換資訊。

自定義 HTTP 交換記錄

要自定義每個記錄的交換中包含的專案,請使用 management.httpexchanges.recording.include 配置屬性。

要完全停用記錄,請將 management.httpexchanges.recording.enabled 設定為 false