Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
Describe the issue: How to see the payload being send to OpenSearch through the JAVA library.
I tried but I don’t see the actual payload :
final Logger logger2 = LoggerFactory.getLogger(“org.opensearch.client”);
((ch.qos.logback.classic.Logger) logger2).setLevel(Level.DEBUG);
I used the following code but is a lot of boiler plate code that I would like to avoid:
httpClientBuilder.addInterceptorLast( new HttpRequestInterceptor() {
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
if (request instanceof HttpEntityEnclosingRequest) {
var entityRequest = (HttpEntityEnclosingRequest) request;
var entity = entityRequest.getEntity();
if (entity != null) {
var inputStream = entity.getContent();
var scanner = new Scanner(inputStream, StandardCharsets.UTF_8.name()).useDelimiter(“\A”);
var requestBody = scanner.next();
scanner.close();
var method = request.getRequestLine().getMethod();
logger.info(“OpenSearch, Method: ‘{}’ request {}”, method, requestBody);
}
}
}
}
);
Configuration:
Relevant Logs or Screenshots: