日志拦截器

 private OkHttpClientUtils() {
        //创建拦截器对象
        HttpLoggingInterceptor httpLoggingInterceptor=new HttpLoggingInterceptor();
        //配置日志拦截器
        httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        okHttpClient = new OkHttpClient.Builder()
           //     .readTimeout(2000,TimeUnit.MICROSECONDS)
                .writeTimeout(2000,TimeUnit.MICROSECONDS)
                .addInterceptor(httpLoggingInterceptor)
                .build();
    }

日志拦截器,在utils层打

需要导依赖 

/*拦截器依赖*/
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'

猜你喜欢

转载自blog.csdn.net/nideyida1/article/details/81805735