rails: Logging stops after a while (thread safety)

We are having an issue where our Rails logs output (to STDOUT) for a few minutes after boot (on Heroku dynos) but then quit. The other Heroku logs continue (router, runtime metrics) so it seems to be a problem in Ruby-land.

<del>This seems to only occur when using log_tags or when enabling the lograge gem: https://github.com/roidrage/lograge/issues/65 </del>

config.log_tags = [
  lambda { |req|
    session = ActiveRecord::SessionStore::Session.find_by_session_id(req.cookie_jar["_jobber_session_id"])
    return unless session
    user_id = session.data["user_credentials_id"]
    "user_id=#{user_id}" if user_id
  }
]

MRI 2.1, Rails 4.0.2, Puma 2.7.1 with <del>8 threads</del> 6 threads.

Last week we upgraded from Rails 3.2.16 to 4.0.2. We believe that is when the issue surfaced, though a few weeks ago we switched from Unicorn to Puma as well.

Has anyone else ran into an issue like this? Particularly with a threaded web server.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 17 (16 by maintainers)

Most upvoted comments

Just for posterity. I had a similar issue upgrading from Rails 3 to Rails 4. Logging to STDOUT stopped (after one request) because of the obsolete quiet_assets gem still in my Gemfile. Removing this gem fixed the issue (and adding config.assets.quiet = true to environments/development.rb).