Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Logging from rake tasks is broken in production environment

#543

To reproduce, create a fresh Rails project, put the attached test_logging.rake file inside /lib/tasks, and then run:

rake test_logging RAILS_ENV=production

The test_logging task calls RAILS_DEFAULT_LOGGER.info, so the logged text should appear in the production.log file, but it does not.

I've reproduced in 2.0.2 and 2.1. Other folks have reported the same problem here:

http://www.ruby-forum.com/topic/...

Reported by Michael Lovitt · July 3rd, 2008 @ 01:53 PM

State: resolved
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Michael Lovitt
  2. josh
    josh
    • State changed from new to wontfix

    October 5th, 2008 @ 03:18 PM

  3. David Muir
    David Muir

    eh? why is this a wontfix?
    I just wasted half my day trying to figure out why I wasn't getting any logs...
    Can this be overridden via the production.rb?
    If not, is my only option to run all my rake tasks in development mode?

    October 30th, 2009 @ 05:13 AM

  4. Ryan Bigg
    Ryan Bigg
    • State changed from wontfix to open
    • Importance changed from to

    This is still happening. This should not be marked as "wontfix" without a good reason.

    April 2nd, 2011 @ 12:32 AM

  5. Ryan Bigg
    Ryan Bigg

    If you come across this error, it's because you're not flushing the log output. Use this which will automatically flush the log on every log call:

    Rails.logger.auto_flushing = true

    April 2nd, 2011 @ 12:36 AM

  6. Ryan Bigg
    Ryan Bigg
    • State changed from open to resolved

    April 2nd, 2011 @ 12:36 AM