Search code examples
javaloggingquarkusquarkus-rest-client

Add logging to all RestClient calls in Quarkus


I have a minimal Quarkus RestClient implemented, much like the example on documentation (https://quarkus.io/guides/rest-client):

package org.acme.rest.client;

import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import org.jboss.resteasy.annotations.jaxrs.PathParam;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import java.util.Set;

@Path("/v2")
@RegisterRestClient
public interface CountriesService {

    @GET
    @Path("/name/{name}")
    Set<Country> getByName(@PathParam String name);
}

How can I enable logging for all the calls to the client above?
I need to display full URI, query parameters and HTTP response code even if the later shows up on a separate line.


Solution

  • Use a ClientResponseFilter; create a concrete implementation of that interface and trace what you want.
    Just remember to register the filter on CountriesService with @RegisterProvider annotation.