For security reasons I don't wish to have Sinatra print every URL its requested in standard output, I've tried using set :logging, false
as suggested in this answer using:
class SweetAppName< Sinatra::Base
set :show_exceptions, false
set :environment, :production
set :logging, false
However when I run the app using rackup and thin, I still see the request logged to the terminal:
127.0.0.1 - - [26/May/2015:09:32:34 -0700] "GET /not-a-real-url HTTP/1.0" 404 - 0.0452
How can I turn these off?
If you start your app with rackup
, Rack will add some middleware, including logging. You can prevent this by using the quiet option (-q
or --quiet
) to rackup
, i.e. from the command line:
$ rackup -q
You can include this option in your config.ru
if you want, so you don’t have to remember typing it every time you start your app. The first line that starts with #\
is parsed as options, so you can have a config.ru
like this:
#\ --quiet
# other middleware etc...
run SweetAppName
If you use the classic Sinatra app style you will need to add the set :logging, false
line, otherwise Sinatra will add its own logging. With the modular style (like you are using in the question) this setting defaults to false
so you shouldn’t need it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With