Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7023025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:39:28+00:00 2026-05-27T23:39:28+00:00

I am using the ruby gem rest-client with rest-client-components . Rest-client-components enables request logging

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:39:29+00:00Added an answer on May 27, 2026 at 11:39 pm

    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.

    # lib/rest_client_logger.rb
    class RestClientLogger < ActiveSupport::BufferedLogger
      def write(msg)
        add(INFO, msg)
      end
    end
    

    Then tell Rails to use your new logger.

    # application.rb
    log_file = File.open("log/#{Rails.env}.log", 'a')
    log_file.sync = true  # turn on auto-flushing at the file level so we get complete messages
    config.logger = RestClientLogger.new(log_file)
    config.logger.auto_flushing = !Rails.env.production?  # turn off auto-flushing at the logger level in production for better performance
    

    Finally, tell rest-client to use your new logger.

    # config/initializers/rest_client.rb
    RestClient.enable Rack::CommonLogger, Rails.logger
    

    Limitations:

    If you’re using Rack::Cache with rest-client-components, this doesn’t capture the cache messages.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to post to a REST resource by using ruby rest-client gem. The
I'm writing a Ruby interface to Fluidinfo , using the rest-client gem as a
I'm using Rest-client gem in ruby.My code is as follows.., require 'rest_client' puts RestClient.get
I have been trying to use the ruby-git gem to make commits etc from
Using Your Ruby Gem(s) You will need to add /home/username/ruby/gems to the include path.
I am using the ruby daemons gem to create a custom daemon for my
I'm using the ruby serial port gem. After I open up the port I
I am working on creating a daemon in Ruby using the daemons gem. I
We're thinking about using the rufus-scheduler gem on a Ruby on Rails project to
I'm using gem bundler (v.0.9.6) and Rails 2.3.5, rubygems 1.3.6 and ruby 1.8.7 (On

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.