In my Rails project, I noticed that sometimes actions are not written into the log file development.log immediately after they are done, but rather after some other actions are done (or maybe just after some amount of time, I’m not sure.) Exactly when is the development.log file written?
In my Rails project, I noticed that sometimes actions are not written into the
Share
Updated for Rails 3.2
The default logging for Rails is buffered, so log message are not written immediately, but happen in batches. You can force the logger to flush the buffer with:That was the old way, as of 3.2 the filesystem handles buffering before writing the log:
You can change your config/environments/development.rb to auto flush with every log message:
This is used by bootstrap.rb to force the sync of the log (e.g.
f.sync = true). This will noticeable impact performance.