title: What is the fastest Ruby logger implementation?
body: <p>I want to find the fastest logger Ruby has to offer.  My intuition tells me that syslog would win in this race.  But my intuition seems to be wrong.  Syslog turns out to be the slowest out of the three loggers I've tested.  I'm using my MacBook Pro, OSX 10.6 (Snow Leopard), Intel Core2 Duo, 4GB of RAM and Ruby 1.8.7 built from MacPorts.  Am I doing something wrong?  Or Ruby's syslog implementation is just that slow?  Feel free to post your results if they're different from mine. You are also welcome to add your favorite Ruby logger to the benchmark. My goal is to find the fastest logger available.  I'm only interested in pure performance (throughput).  Features like multi-target logging is not the concern here.</p>
  
  <pre><code># loggers_bench.rb
  
  require 'rbench'
  require 'activesupport'
  require 'syslog'
  require 'logger'
  
  buffered = ActiveSupport::BufferedLogger.new('buffered.log')
  logger   = Logger.new('logger.log')
  syslog   = Syslog.open('rb_syslog')
  
  TIMES = 10_000
  
  RBench.run(TIMES) do
    column :syslog,    :title =&gt; 'Syslog'
    column :logger,    :title =&gt; 'Logger'
    column :buffered,  :title =&gt; 'ActiveSuppoort::BufferedLogger'
  
  
    report '#info' do
      syslog {
        300.times do |i|
          syslog.info "hello #{i}"
        end
      }
  
      logger {
        300.times do |i|
          logger.info "#{Time.now} logging_logger[Process.pid]:  INFO  logging_logger : hello #{i}"
        end
      }
      buffered {
        300.times do |i|
          buffered.info "#{Time.now} logging_logger[Process.pid]:  INFO  logging_logger : hello #{i}"
        end
      }
  
    end
  end
  
  # &gt; RUBYOPT=rubygems ruby loggers_bench.rb 
  #                Syslog |  Logger | ActiveSuppoort::BufferedLogger|
  # -----------------------------------------------------------------
  # #info         158.316 | 117.882 |                        98.707 |
  </code></pre>
  
  <p>Note that I've only used the simpler form: "hello #{i}" for Syslog (in theory this should be even faster, but it's not).  Also my Mac's default syslogd seems to have a limited messages quota (500/sec).  The following message is generated from time to time in the syslog:</p>
  
  <pre><code>*** process 1962 exceeded 500 log message per second limit  -  remaining messages this second discarded ***
  </code></pre>