{"id":8075,"date":"2015-11-24T23:20:32","date_gmt":"2015-11-24T23:20:32","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/11\/24\/how-can-i-log-each-request-response-using-alamofire-open-source-projects-alamofire-alamofire\/"},"modified":"2022-08-30T15:03:02","modified_gmt":"2022-08-30T15:03:02","slug":"how-can-i-log-each-request-response-using-alamofire-open-source-projects-alamofire-alamofire","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/11\/24\/how-can-i-log-each-request-response-using-alamofire-open-source-projects-alamofire-alamofire\/","title":{"rendered":"How can I log each request\/response using Alamofire?-open source projects Alamofire\/Alamofire"},"content":{"rendered":"<p><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e746ef9b7169cdff1d79a534e6fdbf3a?s=128&amp;d=identicon&amp;r=PG\" \/> <strong>clozach<\/strong><\/p>\n<p>Something like this might be what you were looking for:<\/p>\n<pre><code>extension Request {\n   public func debugLog() -&gt; Self {\n      #if DEBUG\n         debugPrint(self)\n      #endif\n      return self\n   }\n}\n<\/code><\/pre>\n<p>Usage:<\/p>\n<pre><code>Alamofire.request(.GET, \"http:\/\/httpbin.org\/get\", parameters: [\"foo\": \"bar\"])\n         .debugLog()\n         .response {\u2026}\n<\/code><\/pre>\n<p>If you want to print all responses, you could write your own response method, similar to the responseObject() method at the top of this tutorial:<\/p>\n<p>http:\/\/www.raywenderlich.com\/87595\/intermediate-alamofire-tutorial<\/p>\n","protected":false},"excerpt":{"rendered":"<p>clozach Something like this might be what you were looking for: extension Request { public func debugLog() -&gt; Self { #if DEBUG debugPrint(self) #endif return self } } Usage: Alamofire.request(.GET, &#8220;http:\/\/httpbin.org\/get&#8221;, parameters: [&#8220;foo&#8221;: &#8220;bar&#8221;]) .debugLog() .response {\u2026} If you want to print all responses, you could write your own response method, similar to the responseObject() [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8075","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8075","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=8075"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8075\/revisions"}],"predecessor-version":[{"id":8645,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8075\/revisions\/8645"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=8075"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=8075"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=8075"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}