> BufferedLogger appears to just implement write buffering, which is
> normally the job of the operating system. I'm assuming I'm missing
> something, but I'm having trouble finding any justification for it
> anywhere. Can someone explain why we have it?
The short version is that logging showed up in hello world benchmarks
and as a result some optimisation, of questionable real world utility,
took place. Buffering up a bunch of writes into a single write does
make a difference though and it seems mostly harmless.
BufferedLogger will reduce the number of write system calls, so there is
some performance benefits there but I also do rather suspect it would be
of little real world gain.
Coupled with the default auto_flushing value in production (1000 lines!)
it's not actually that harmless. If the Rails instance crashes or is
killed, it loses up to 1000 lines of logs.
I've just done a quick test and BufferedLogger isn't automatically
flushed at the end of rake tasks (or when rails console exits), so up to
1000 log lines get lost there too. I'm not that familiar with the full
execution path, but I can't actually see where Rails.logger gets closed
or flushed on Rails app instance shutdown either.
I came across BufferedLogger's behaviour trying to debug a problem in
production by tailing the log file and getting no output (even without
the app being killed). So it makes troubleshooting pretty hard too.
It also has
some nice benefits now that it prevents interleaving of requests in
multi-threaded mode.
as discussed with Hongli, it certainly shouldn't be needed to prevent
interleaving of individual log lines. It doesn't really prevent
interleaving of requests either, it just reduces how often they occur
(which in an app busy enough to notice system call overhead, probably
isn't enough 
You can set your own logger instance in application.rb if you want to
use something simpler / customised.
We're using SysLogLogger in a few places, which is pretty neat.
IMHO though, I think that something simpler than BufferedLogger should
be used by default - it looks to have enough caveats that it should be
only used when fully understanding it's behaviour.
John.