Disable Rack::CommonLogger without monkey patching

I monkey patched the log(env, status, header, began_at) function, which is what gets called by rack to produce the apache style logs. We use jruby with logback so we have no use for all the custom logging that seems to pervade the ruby ecosystem. I suspect fishwife is initalizing the CommonLogger, which might explain why all my attempts to disable it or to configure it with a custom logger fail. Probably puma does something similar. I actually had two instances at one point. One logging with my custom logger (yay) and another one still doing its silly puts statements on stderr. I must say, I'm pretty appalled with the logging hacks in the rack ecosystem. Seems somebody needs a big cluebat to their heads.

Anyway, putting this in our config.ru works for us:

module Rack
  class CommonLogger
    def log(env, status, header, began_at)
      # make rack STFU; our logging middleware takes care of this      
    end
  end
end

In addition to that, I wrote my own logging middleware that uses slf4j with a proper MDC so we get more meaningful request logging.


Puma adds logging middleware to your app if you are in development mode and haven’t set the --quiet option.

To stop Puma logging in development, pass the -q or --quiet option on the command line:

puma -p 3001 -q

or if you are using a Puma config file, add quiet to it.