Adding Correlation Id to the logs

I have been trying to add correlation ID in hibernate search . Tried creating custom HTTP client configure as given in the documentation. But It’s not working .

public class HttpClientConfigurer implements ElasticsearchHttpClientConfigurer {

    public void configure(ElasticsearchHttpClientConfigurationContext context) {
        System.out.println("Setting the correlationId");
        MDC.put("correlationId", UUID.randomUUID().toString());
        System.out.println("The correlationId is set");
        HttpAsyncClientBuilder clientBuilder = context.clientBuilder();
        clientBuilder.setMaxConnPerRoute( 7 );
        clientBuilder.addInterceptorFirst( (HttpResponseInterceptor) (request, httpContext) -> {
            System.out.println("Checkpoint 2");
        } );;

Added this in the properties : = com.broadridge.basmsp.configuration.HttpClientConfigurer

Need to add correlation Id here in the request :

2022-09-26 12:51:33.132 TRACE [     ] 11712 --- [port thread - 1]         : HSEARCH400093: Executed Elasticsearch HTTP POST request to 'http://localhost:9200' with path 'read', query parameters {from=0, size=25, track_total_hits=true} and 1 objects in payload in 15ms. Response had status 200 'OK'. Request body: <{"query":{"bool":{"must":{"bool":POST}...},"hits":{"total":{"value":0,"relation":"eq"},"hits":[]}}>

This was asked on Stackoverflow as well: Hibernate Search Adding Correlation Id to the request - Stack Overflow

Anyone with an answer, please answer there.