I have added Resque to my Rails 3 project. I have created a job which reads/writes some stuff from/to the DB.
The problem is I do not see the SQL query logs such as "Post Load (0.5ms) SELECT "posts".* FROM "posts"" in the terminal anymore. I am also not seeing any Rails.logger messages I have set up.
When I make yet another request (simple refresh) the logger messages and SQL query logs suddenly show up.
Any ideas what could be going on? Thanks
Rails won't write out to the log file immediately, it waits for a certain amount of lines to go by before flushing the file. You can tell Rails to always flush the log by adding this to your development.rb
or application.rb
file...
config.logger.auto_flushing = true
Only ever do this in development, and never set this in production as it will just kill your I/O.
You can also do it on demand with...
Rails.logger.flush
API documentation here...
http://api.rubyonrails.org/classes/ActiveSupport/BufferedLogger.html#method-i-auto_flushing-3D
We experienced the same issue in one of our projects. Additionally we wanted to log all Resque messages to a separate log file too.
In the blog post Enable immediate log messages of resque workers a code sample can be found to enable the immediate logging to a separate file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With