I am using the ruby gem rest-client with rest-client-components.
Rest-client-components enables request logging with Rack::CommonLogger.
The instructions for enabling it make use of STDOUT:
require 'restclient/components'
RestClient.enable Rack::CommonLogger, STDOUT
This works fine in development, but when I’m in production with Apache/Passenger (mod_rails), I don’t see any messages from rest-client in production.log. Is there a way to integrate Rack::CommonLogger with the Rails log? Or at least to write it to a file? The former is more useful because it’s easy to see the context, but the latter is better than nothing.
Thanks.
Here’s the solution I came up with.
Thanks to @crohr for pointing me in the right direction.
First, create a new Logger class. Rails defaults to ActiveSupport::BufferedLogger, so we’ll extend that.
Then tell Rails to use your new logger.
Finally, tell rest-client to use your new logger.
Limitations:
If you’re using Rack::Cache with rest-client-components, this doesn’t capture the cache messages.