How can I access the Rails logger from an initializer?

abeger picture abeger · Jan 22, 2010 · Viewed 9.7k times · Source

Following the advice from my previous question, I placed my background process in an initializer named scheduler.rb. However, I'm having a hard time getting the newly-scheduled processes to log to the Rails logs. Is there a simple way for me to access the same logs from the initializer, preferably by accessing Rails' default logger methods (logger.info, etc)?

Answer

Hertzel Guinness picture Hertzel Guinness · May 12, 2012

Rails 3-
Simply use Rails.logger in your initializer

Rails.logger.info "blabla"

HTH