Retrofitではログを印刷しません。ログレベルを冗長に設定します。 HttpLoggingInterceptorも試してみました。あなたは、ログが表示されていない理由を私は知らないが、ここでは正常に動作します私のコードの一部であるこれらのgradlesAndroid Retrofitログが表示されない
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'
コード実際に
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", "[email protected]#JG_a34-n3d")
.method(original.method(), original.body());
Request request = requestBuilder.build();
return chain.proceed(request);
}
})
.addInterceptor(httpLoggingInterceptor);
return httpClient;
UさんがOkHttpClientを改造しましたか? – Esperanz0
あなたの問題に対する答えが見つかったのでしょうか? – sanevys
@sanevysはい...私は正しいと回答をマークしました –