为了账号安全,请及时绑定邮箱和手机立即绑定

使用Retroeft 2进行日志记录

使用Retroeft 2进行日志记录

慕的地8271018 2019-07-10 10:46:44
使用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上的吗?
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 398 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号