Retrofit @GET - how to display request string?

后端 未结 3 602
挽巷
挽巷 2021-02-18 19:22

I\'m working on an Android application that uses Retrofit to create a restful client. In order to debug networks calls, I would like to display or dump the url that\'s actually

3条回答
  •  情话喂你
    2021-02-18 20:00

    RetrofitError has a getUrl() method that returns the URL.

    Also the Response has a getUrl() method as well within the callback.

    That, and you can also specify the log level as per this question:

    RestAdapter adapter = (new RestAdapter.Builder()).
    //...
               setLogLevel(LogLevel.FULL).setLog(new AndroidLog("YOUR_LOG_TAG"))              
    

    Although based on the docs, LogLevel.BASIC should do what you need.

    BASIC
    Log only the request method and URL and the response status code and execution time.
    

提交回复
热议问题