Retrofit 2.x : Log Header for request and response

后端 未结 5 1459
傲寒
傲寒 2021-02-13 03:17

I am using retrofit 2.x and i want to log the header and body of request and response .

  HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
            


        
5条回答
  •  孤独总比滥情好
    2021-02-13 03:44

    Instead of using addInterceptor to add the logging interceptor, use addNetworkInterceptor, to include headers added by OkHttp.

    Network interceptors are able to:

    Observe the data just as it will be transmitted over the network.

提交回复
热议问题