         console.timeEnd 'Recurly API request'
 
         # Parse XML and build JS object, or list of errors.
-        xml2js.parseString body, (err, result)->
+        xml2js.parseString body, (err, result)=>
           if err
             callback [new models.Error 'xml', 'Invalid XML']
+            log "error",{paymentMethodId, operation, data: err}
           else if result.error
             callback [new models.Error result.error.symbol[0], result.error.description[0]._]
+            log "error", {paymentMethodId, operation, data: result.error}
           else if result.errors
             # See https://docs.recurly.com/api/basics/validation-errors for XML format
             errors = []

              else
                errors.push new models.Error err1, err1
            callback errors
          else
            # Find next page's URL if necessary
            nextUrl = parseNextUrl res  if res.headers.link
            callback null, result, nextUrl

    req.on 'error', (e)->
      callback [new models.Error 'connection', 'Unable to connect to payment backend.']

    req.end(data, 'utf8')
      options.headers['Content-Type'] = 'application/xml; charset=UTF-8'

    console.time 'Recurly API request'
    log "info", {paymentMethodId, operation, data}

    req = https.request options, (res)->
      res.setEncoding 'utf8'
