Retrofit does not print log. Log level set to verbose. Tried HttpLoggingInterceptor too.
using these gradles
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'
Code
OkHttpClient httpClient = new OkHttpClient();
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
httpClient.newBuilder().connectTimeout(6, TimeUnit.MINUTES)
.readTimeout(6, TimeUnit.MINUTES)
.writeTimeout(6, TimeUnit.MINUTES)
.addInterceptor(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request original = chain.request();
Request.Builder requestBuilder = original.newBuilder()
.header("Content-Type", "application/json")
.header("Authorization", "aDRF@F#JG_a34-n3d")
.method(original.method(), original.body());
Request request = requestBuilder.build();
return chain.proceed(request);
}
})
.addInterceptor(httpLoggingInterceptor);
return httpClient;
In some cases you need to allow extended logs on certain physical android devices. This can be done in developers menu in the android phone settings.
On some devices (emulator or real Android ones) logging is by default disabled. You need to enable this option to see the logs. Tried this with Meizu M3s.
Go to Developer Options.
Find Performance optimization.
Find Advanced logging.
Allow all.
Please note that for different devices the steps might be slightly different.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With