我正在使用Retrofit,并且想记录我的响应和其他内容,我正在使用这种https://futurestud.io/tutorials/retrofit-2-log-requests-and-responses类型,但是我遇到了无法解决setLevel 错误
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(Level.BODY); // i am getting error on this
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(logging); //this is also getting error
我正在用这个编译'com.squareup.okhttp3:logging-interceptor:3.3.1'并进行改造
编译'com.squareup.retrofit2:converter-gson:2.1.0'依赖项。
最佳答案
在interceptor
方法中编写您的getClient()
代码,例如
public class RestClient {
public getClient() {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
}
}