Class ClientLogger

java.lang.Object
org.springframework.data.elasticsearch.client.ClientLogger

public abstract class ClientLogger extends Object
Logging Utility to log client requests and responses. Logs client requests and responses to Elasticsearch to a dedicated logger: org.springframework.data.elasticsearch.client.WIRE on trace level.
Since:
3.2
Author:
Mark Paluch, Christoph Strobl, Peter-Josef Meisch, Oliver Drotbohm
  • Method Details

    • isEnabled

      public static boolean isEnabled()
      Returns true if the logger is enabled.
      Returns:
      true if the logger is enabled.
    • logRequest

      public static void logRequest(String logId, String method, String endpoint, Object parameters)
      Log an outgoing HTTP request.
      Parameters:
      logId - the correlation id, see newLogId().
      method - HTTP method
      endpoint - URI
      parameters - optional parameters.
    • logRequest

      public static void logRequest(String logId, String method, String endpoint, Object parameters, String headers)
      Log an outgoing HTTP request.
      Parameters:
      logId - the correlation id, see newLogId().
      method - HTTP method
      endpoint - URI
      parameters - optional parameters.
      headers - a String containing the headers
      Since:
      4.4
    • logRequest

      public static void logRequest(String logId, String method, String endpoint, Object parameters, Supplier<Object> body)
      Log an outgoing HTTP request with a request body.
      Parameters:
      logId - the correlation id, see newLogId().
      method - HTTP method
      endpoint - URI
      parameters - optional parameters.
      body - body content supplier.
    • logRequest

      public static void logRequest(String logId, String method, String endpoint, Object parameters, String headers, Supplier<Object> body)
      Log an outgoing HTTP request with a request body.
      Parameters:
      logId - the correlation id, see newLogId().
      method - HTTP method
      endpoint - URI
      parameters - optional parameters.
      headers - a String containing the headers
      body - body content supplier.
      Since:
      4.4
    • logRawResponse

      public static void logRawResponse(String logId, @Nullable HttpStatusCode statusCode)
      Log a raw HTTP response without logging the body.
      Parameters:
      logId - the correlation id, see newLogId().
      statusCode - the HTTP status code.
    • logRawResponse

      public static void logRawResponse(String logId, @Nullable HttpStatus statusCode, String headers)
      Log a raw HTTP response without logging the body.
      Parameters:
      logId - the correlation id, see newLogId().
      statusCode - the HTTP status code.
      headers - a String containing the headers
    • logResponse

      public static void logResponse(String logId, HttpStatusCode statusCode, String body)
      Log a raw HTTP response along with the body.
      Parameters:
      logId - the correlation id, see newLogId().
      statusCode - the HTTP status code.
      body - body content.
    • logResponse

      public static void logResponse(String logId, @Nullable HttpStatus statusCode, String headers, String body)
      Log a raw HTTP response along with the body.
      Parameters:
      logId - the correlation id, see newLogId().
      statusCode - the HTTP status code.
      headers - a String containing the headers
      body - body content.
      Since:
      4.4
    • newLogId

      public static String newLogId()
      Creates a new, unique correlation id to improve tracing across log events.
      Returns:
      a new, unique correlation id.