Sinatra: three logs

陌路散爱 提交于 2019-12-22 15:33:33

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!