static public void logResponseDetails(HttpResponse response, SFLogger logger)
  {
    if (response == null)
    {
      logger.error("null response");
      return;
    }

    // log the response
    if (response.getStatusLine() != null)
    {
      logger.error("Response status line reason: {}",
                   response.getStatusLine().getReasonPhrase());
    }

    // log each header from response
    Header[] headers = response.getAllHeaders();
    if (headers != null)
    {
      for (Header header : headers)
      {
        logger.error("Header name: {}, value: {}",
                     header.getName(), header.getValue());
      }
    }

    // log response
    if (response.getEntity() != null)
    {
      try
      {
        StringWriter writer = new StringWriter();
        BufferedReader bufferedReader = new BufferedReader(
            new InputStreamReader((response.getEntity().getContent())));
        IOUtils.copy(bufferedReader, writer);
        logger.error("Response content: {}", writer.toString());
      }
      catch (IOException ex)
      {
        logger.error("Failed to read content due to exception: "
                     + "{}", ex.getMessage());
      }
    }
  }
static public void logResponseDetails ( HttpResponse response , SFLogger logger ) { if ( response == null ) { logger . error ( "null response" ) ; return ; } if ( response . getStatusLine ( ) != null ) { logger . error ( "Response status line reason: {}" , response . getStatusLine ( ) . getReasonPhrase ( ) ) ; } Header [ ] headers = response . getAllHeaders ( ) ; if ( headers != null ) { for ( Header header : headers ) { logger . error ( "Header name: {}, value: {}" , header . getName ( ) , header . getValue ( ) ) ; } } if ( response . getEntity ( ) != null ) { try { StringWriter writer = new StringWriter ( ) ; BufferedReader bufferedReader = new BufferedReader ( new InputStreamReader ( ( response . getEntity ( ) . getContent ( ) ) ) ) ; IOUtils . copy ( bufferedReader , writer ) ; logger . error ( "Response content: {}" , writer . toString ( ) ) ; } catch ( IOException ex ) { logger . error ( "Failed to read content due to exception: " + "{}" , ex . getMessage ( ) ) ; } } }
A utility to log response details.
<p>
Used when there is an error in http response
</p>

@param response http response get from server
@param logger   logger object