I am using retrofit 2.x and i want to log the header and body of request and response .
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
You need to set following:
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.HEADERS);
clientBuilder.addNetworkInterceptor(httpLoggingInterceptor);
clientBuilder.build()