-1

I made a query to server, but got an error. Please, tell me, how can I look inside my query to see where is the mistake. How do I log the API call in Retrofit 2?

danday74
  • 52,471
  • 49
  • 232
  • 283

1 Answers1

1

You can log all requests by using Interceptor to Retrofit HttpClient for example you can add HttpInterceptor dependency in OkHttp by following steps in gradle file:

compile 'com.squareup.okhttp3:logging-interceptor:3.4.0'

and then

OKHttp client = ....
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
client.interceptors().add(interceptor);

Retrofit retrofit = new Retrofit.Builder()
            .baseUrl("url")
            .client(client) // add custom OkHttp client
Cătălin Florescu
  • 5,012
  • 1
  • 25
  • 36
Faraz Ahmed
  • 1,245
  • 1
  • 14
  • 24