Search code examples
javaandroidrestloggingrest-client

CRest log request / response body


Is there any way to print the request body that CRest (codegist) generates before sending it?

Similarly is it possible to print the response raw body after receiving it?

It would be very helpful for debugging.

I'm using CRest for an Android project.


Solution

  • You can turn on Crest logging in Android in two ways:

    • execute a shell command on your connected device:

      MBP:~ roman$adb shell setprop log.tag.CodeGist VERBOSE
      
    • set the same property programmatically using the System.setProperty() method

    The raw response will be printed out in the logs like this:

    03-18 07:58:52.774: VERBOSE/CodeGist(1590): org.codegist.crest.io.Response: Received Http Response
    03-18 07:58:52.784: VERBOSE/CodeGist(1590): org.codegist.crest.io.Response: [{"id":14306037}]