使用 SpringBoot 应用程序从 ElasticSearch Transport 客户端记录 request/response

Log request/response from ElasticSearch Transport client with SpringBoot application

我在我的 SpringBoot 应用程序中使用 ElasticSearch 的传输客户端。 Logback 用作我的日志记录实现。

有没有办法从 ElasticSearch Transport 客户端启用 request/response 的日志记录以帮助进行故障排除?

为了将请求记录到 Elastic Search,在 SearchRequestBuilder 上执行 toString 应该会为您提供实际的 JSON 请求。 为了记录响应,在 SearchResponse 上执行 toString 应该会给你实际的 JSON 响应。