-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
  • 45,909
  • 39
  • 198
  • 245

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
Florescu Cătălin
  • 4,684
  • 1
  • 23
  • 33
Faraz Ahmed
  • 1,229
  • 1
  • 14
  • 23