Retrofit @GET - how to display request string?

后端 未结 3 604
挽巷
挽巷 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 19:53

    Yes, you can enable debug logging by calling setLogLevel() on your RestAdapter.

    I typically set logging to LogLevel.FULL for debug builds like so:

    RestAdapter adapter = builder.setEndpoint("example.com")
        .setLogLevel(BuildConfig.DEBUG ? RestAdapter.LogLevel.FULL : RestAdapter.LogLevel.NONE)
        .build();
    

    This will automatically print out all of the information associated with your HTTP requests, including the URL you are hitting, the headers, and the body of both the request and the response.

提交回复
热议问题