Ruby applications which make HTTP calls to external services such as Websolr or Bonsai Elasticsearch may find it beneficial to use the net-http-spy gem to intercept and log HTTP calls made to that service. This is a very thorough way to log all communication between your application and the external service, which is very helpful when you need to troubleshoot an issue.
gem 'net-http-spy'
Net::HTTP.http_logger_options = { :verbose => true, :body => true }
Net::HTTP.http_logger = Logger.new(STDOUT)
I have chosen in this example to log to STDOUT, which is ideal for Heroku apps. You may want to log to a file, such as Rails.root.join('log/net-http-spy.log')
. You should refer to the net-http-spy readme on GitHub for additional information about configuring net-http-spy.