file = File.open("log/production.log", "w")
file.sync = true
Rails.logger = ActiveSupport::BufferedLogger.new(file) file = File.open("log/production.log", "w")
file.sync = true
Rails.logger = ActiveSupport::BufferedLogger.new(file)But this is not my point, for me rails has been about sane defaults - this is what makes it fun to start and easy to work with. I just don't see why we fix something that is not broken at all.
They decided to get rid of supposedly unneeded cruft that was hard to maintain and delegate file handling functions to OS.
1. This commit changed two things: default file mode of open logs is no more sync in production (i.e. it is not automatically flushed by ruby write routines) AND it doesn't buffer log entries anymore (which is actually funny, since, you know, it is called ActiveSupport::BufferedLogger) 2. When IO#sync is false, which was the case, ruby didn't flush upon every write. That manifested itself in logfile entries not appearing immediately after write. 2.1. In some 3.2 release they've reversed that, so sync = true is by default in all latest versions of rails. 3. Since logger doesn't buffer requests anymore, the problem of interleaving messages should still be there, sorry for confusion. 3.1. To solve this, you can either use tag features of recent rails or port older buffered logger itself.