Reputation: 4643
i basically want want use both of below features
// logging
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(logging)
.build();
// time out
OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(300, TimeUnit.SECONDS)
.readTimeout(300,TimeUnit.SECONDS).build();
Upvotes: 1
Views: 929
Reputation: 2506
Just add it there:
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(logging)
.connectTimeout(300, TimeUnit.SECONDS)
.readTimeout(300,TimeUnit.SECONDS)
.build();
Upvotes: 1
Reputation: 1078
Just use builder with both interceptor and timeouts.
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(logging)
.connectTimeout(300, TimeUnit.SECONDS)
.readTimeout(300,TimeUnit.SECONDS)
.build();
Upvotes: 1