Sinatra: three logs

2019-05-23 22:49发布

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条回答
倾城 Initia
2楼-- · 2019-05-23 23:24

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
查看更多
登录 后发表回答