Class ClientLogger
java.lang.Object
org.springframework.data.elasticsearch.client.ClientLogger
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 Summary
Modifier and TypeMethodDescriptionstatic boolean
Returns true if the logger is enabled.static void
logRawResponse
(String logId, HttpStatusCode statusCode) Log a raw HTTP response without logging the body.static void
logRawResponse
(String logId, HttpStatus statusCode, String headers) Log a raw HTTP response without logging the body.static void
logRequest
(String logId, String method, String endpoint, Object parameters) Log an outgoing HTTP request.static void
Log an outgoing HTTP request.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.static void
Log an outgoing HTTP request with a request body.static void
logResponse
(String logId, HttpStatusCode statusCode, String body) Log a raw HTTP response along with the body.static void
logResponse
(String logId, HttpStatus statusCode, String headers, String body) Log a raw HTTP response along with the body.static String
newLogId()
Creates a new, unique correlation id to improve tracing across log events.
-
Method Details
-
isEnabled
public static boolean isEnabled()Returns true if the logger is enabled.- Returns:
- true if the logger is enabled.
-
logRequest
Log an outgoing HTTP request.- Parameters:
logId
- the correlation id, seenewLogId()
.method
- HTTP methodendpoint
- URIparameters
- 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, seenewLogId()
.method
- HTTP methodendpoint
- URIparameters
- 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, seenewLogId()
.method
- HTTP methodendpoint
- URIparameters
- 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, seenewLogId()
.method
- HTTP methodendpoint
- URIparameters
- optional parameters.headers
- a String containing the headersbody
- body content supplier.- Since:
- 4.4
-
logRawResponse
Log a raw HTTP response without logging the body.- Parameters:
logId
- the correlation id, seenewLogId()
.statusCode
- the HTTP status code.
-
logRawResponse
Log a raw HTTP response without logging the body.- Parameters:
logId
- the correlation id, seenewLogId()
.statusCode
- the HTTP status code.headers
- a String containing the headers
-
logResponse
Log a raw HTTP response along with the body.- Parameters:
logId
- the correlation id, seenewLogId()
.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, seenewLogId()
.statusCode
- the HTTP status code.headers
- a String containing the headersbody
- body content.- Since:
- 4.4
-
newLogId
Creates a new, unique correlation id to improve tracing across log events.- Returns:
- a new, unique correlation id.
-