Retrofit调试,生成网络请求信息

Retrofit debug, generate network request information

我正在使用改造来发出一些网络请求,但不确定要使用哪个@annotation,我设法使用 PostMan Utility 成功请求,但无法在 android 应用程序上正确请求。因此我想从网络检查器进行调试。

如何使用我的 android app/emulator 生成类似于下面的 log/report?

POST /path/to/api/ HTTP/1.1
Content-Length: [length]
Content-Type: multipart/form-data; boundary=iSBcxYW-SeE_dubqNJw3p6PP59WbDOAj

--iSBcxYW-SeE_dubqNJw3p6PP59WbDOAj
Content-Disposition: form-data; name="file"

test
--iSBcxYW-SeE_dubqNJw3p6PP59WbDOAj--

您可以设置日志级别以在您的 restadapter 中查看日志以进行改造:-

 RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint(your_url_endpoint)
            .setRequestInterceptor(requestInterceptor)
            .setLogLevel(RestAdapter.LogLevel.FULL)
            .setLog(new AndroidLog("your log tag"))
            .build();