Search code examples
rubysinatrarackpuma

Disable Rack::CommonLogger without monkey patching


So, I want to have completely custom logging for my sinatra application, but I can't seem to disable the Rack::CommonLogger.

As per the sinatra docs all I should need to do is add the following line (tried setting it to false as well):

set :logging, nil

to my configuration. This does not work however, and I still receive the Apache-like log messages in my terminal. So the only solution I've found so far is to monkey patch the damn thing.

module Rack
  class CommonLogger
    def call(env)
      # do nothing
      @app.call(env)
    end
  end
end

Anyone got any ideas if it's possible to disable this without restorting to such matters?


Solution

  • 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.