title: ClientHttpRequestInterceptor not called in springboot
body: <p>I am trying to add logging to my application using ClientHttpRequestInterceptor.My interceptor is not being called.
  Not sure what is going wrong here -</p>
  
  <p>Here is my code -</p>
  
  <pre><code>    @Component
      @Slf4j
      public final class RestTemplateInterceptor implements ClientHttpRequestInterceptor {
  
  
        protected static final LoggingAspect aspect = new LoggingAspect();
        private final RequestContext requestContext;
        private boolean logResponseBody = true;
  
  
        public RestTemplateInterceptor(RequestContext requestContext) {
          this.requestContext = requestContext;
        }
  
  
        @Override
        public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution clientHttpRequestExecution) throws IOException {
          populateHeader(request);
          traceRequest(request, body);
          ClientHttpResponse response = clientHttpRequestExecution.execute(request,body);
          traceResponse(response);
          return response;
        }
  
  
        private void populateHeader(HttpRequest request) {
          final HttpHeaders headers = request.getHeaders();
  
          // Propagate TAM headers
          headers.add("iv-user", requestContext.getUser());
          headers.add("MessageId", requestContext.getMessageId());
          headers.add("CorrelationId", requestContext.getConversationId());
          headers.add("BusinessId", requestContext.getBusinessId());
          headers.add("ApplicationName", requestContext.getSourceSystem());
          headers.add("iv-groups", requestContext.getGroups());
          headers.add("MessageDateTime", requestContext.getSourceTimestamp());
      }
  ...................
  </code></pre>
  
  <p>Here is my config file</p>
  
  <pre><code>@Configuration
  public class RestTemplateConfig {
    /**
     * initialise restTemplate
     *
     * @param restTemplateInterceptor autowired in RestTemplateInterceptor
     * @return
     */
    @Bean
    public RestTemplate restTemplate(ClientHttpRequestInterceptor restTemplateInterceptor, ObjectMapper objectMapper) {
  
      RestTemplate restTemplate = new RestTemplate(new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory()));
  
      List&lt;ClientHttpRequestInterceptor&gt; interceptors = restTemplate.getInterceptors();
      if (CollectionUtils.isEmpty(interceptors)) {
        interceptors = new ArrayList&lt;&gt;();
      }
  
      interceptors.add(restTemplateInterceptor);
      restTemplate.setInterceptors(interceptors);
      return restTemplate;
    }
  }
  </code></pre>
  
  <p>Here is my WebMVC file</p>
  
  <pre><code>@Configuration
  public class WebMvcConfig implements WebMvcConfigurer {
  
    @Bean
    public WebMvcConfigurer webAuthentication() {
      return new WebMvcConfigurer() {
        @Override
        public void addInterceptors(InterceptorRegistry registry) {
          //registry.addInterceptor(myInterceptor());
          registry.addInterceptor(new MVCLoggingInterceptor()).addPathPatterns("/api/**");
          registry.addInterceptor(new WebAuthentication()).addPathPatterns("/api/**/");
        }
      };
    }
  
  
  }
  </code></pre>
  
  <p>Here is my application file</p>
  
  <pre><code>@EnableAsync
  @EnableScheduling
  @SpringBootApplication(exclude = { SecurityAutoConfiguration.class })
  
  public class XManagementApplication {
  
    public static void main(String[] args) {
      SpringApplication.run(XManagementApplication.class, args);
    }
  }
  </code></pre>
  
  <p>Can anybody tell why my interceptor class is not called when I try to call any API</p>
  
  <p>Any help would be appreciate?</p>