Personally, I found another way to do this using upgrade 2 and RxJava
First you need to create an OkHttpClient object
private OkHttpClient provideOkHttpClient() { //this is the part where you will see all the logs of retrofit requests //and responses HttpLoggingInterceptor logging = new HttpLoggingInterceptor(); logging.setLevel(HttpLoggingInterceptor.Level.BODY); return new OkHttpClient().newBuilder() .connectTimeout(500, TimeUnit.MILLISECONDS) .readTimeout(500,TimeUnit.MILLISECONDS) .addInterceptor(logging) .build(); }
after creating this object, the next step is to simply use it in the modified constructor
public Retrofit provideRetrofit(OkHttpClient client, GsonConverterFactory convertorFactory,RxJava2CallAdapterFactory adapterFactory) { return new Retrofit.Builder() .baseUrl(mBaseUrl) .addConverterFactory(convertorFactory) .addCallAdapterFactory(adapterFactory) .client(client) .build(); }
one of the attributes that you can assign to Retrofit Builder is the client, install the client for the client from the first function.
After running this code, you can find the OkHttp tag in logcat and you will see the requests and answers you made.
source share