问题
I'm using a very simple Sinatra app that works well. However, every log message is repeated three times. I can bring that down to two by disabling the Sinatra logging with
disable :logging
but I still have two. The messages are slightly different, so I gather they are coming from Rack and somewhere else in the stack too.
How do I completely disable logging of successful web requests?
回答1:
Rack is adding own logging as a middleware try to run
rackup -E none
This removes one log entry. The second one is sinatra native which you've already disable. And the third one is Rack::Lint logging if I remember correctly. General approach is to restructure your app like
app.rb
require 'sinatra/base'
class App < Sinatra::Base
get '/' do
"hello"
end
end
config.ru
require 'myapp'
run MyApp
Or you can run app outside rack
if __FILE__ == $0
App.run!
end
来源:https://stackoverflow.com/questions/4282765/sinatra-three-logs