I would like to print out response body generated by my app to stdout/stderr for debugging purposes. The traffic is server-server so I cannot use client tools to get hold of http traffic.
There is a mention of puts @response.body
in http://api.rubyonrails.org/classes/ActionDispatch/Response.html, however in my app controller @response
is undefined. Is there a way for me to print response body to logs in my rails app, and if so, how?
Based on the answer given, did it like this:
after_filter :print_response_body, :only => [:index]
def print_response_body
$stderr.puts response.body
end
In your controller, try
after_filter do
puts response.body
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With