pachl
5/21/2008 11:22:00 PM
When using the native ruby logger, is it save to have multiple
processes writing to the same log file?
For instance, I have the following ruby source example:
# test.rb
require 'logger'
log = Logger.new('/tmp/RLOG')
20.times do
log.error "PID: #{$$}"
sleep 1
end
log.close
# end test.rb
Then I execute like so:
$ ruby test.rb & ruby test.rb & ruby test.rb
After inspection of the log file, each process logged 20 times, all
messages interleaved of course. It looks like it works, but am I
delusional? I'm on an OpenBSD box. Does the OS handle caching/writing
from multiple sources?
-pachl