Retrofit 2.x : Log Header for request and response

后端 未结 5 1451
傲寒
傲寒 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:24

    May it help someone ...

    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.HEADERS);
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    

    Add both to see complete logs and add this interceptor at the last (don't know why but its like this).

提交回复
热议问题