使用Retroeft 2进行日志记录我正在试图获得请求中发送的确切的JSON。这是我的代码:OkHttpClient client = new OkHttpClient();client.interceptors().add(new Interceptor(){
@Override public com.squareup.okhttp.Response intercept(Chain chain) throws IOException {
Request request = chain.request();
Log.e(String.format("\nrequest:\n%s\nheaders:\n%s",
request.body().toString(), request.headers()));
com.squareup.okhttp.Response response = chain.proceed(request);
return response;
}});Retrofit retrofit = new Retrofit.Builder()
.baseUrl(API_URL)
.addConverterFactory(GsonConverterFactory.create())
.client(client).build();但我只在日志里看到这个:request:com.squareup.okhttp.RequestBody$1@3ff4074dheaders:Content-Type: application/vnd.ll.event.list+json考虑到移除setLog()和setLogLevel()我们以前用在Retrofit 1上的吗?
添加回答
举报
0/150
提交
取消
