辛纳特拉测井与堆栈跟踪
目前,我正在运行一个在 Apache/Passenger 上开发的应用程序。当我使用 shotgun 时,我能够查看堆栈跟踪。
我正在尝试使用 Sinatra 设置日志记录,并且真的很开心。我有我的 config.ru:
require 'sinatra'
require 'rubygems'
root = ::File.dirname(__FILE__)
require ::File.join( root, 'application' )
set :environment, :development
set :root, root
set :app_file, File.join(root, 'application.rb')
disable :run
configure :development do
enable :logging, :dump_errors, :raise_errors
end
set :show_exceptions, true if development?
run Application.new
app.rb:
class App < Sinatra::Base
logger = ::File.open("log/development.log", "a+")
STDOUT.reopen(logger)
STDERR.reopen(logger)
Application.use Rack::CommonLogger, logger
end
目前,我能够获取常规日志,但我不需要常规日志。我需要能够在 Web 浏览器或日志中查看我收到的服务器 (500) 错误。任何帮助表示赞赏!
Currently, I'm running an app I'm developing on Apache/Passenger. I was able to view stacktraces when I was using shotgun.
I'm trying to set up logging with Sinatra and really having a hell of a time. I have my config.ru:
require 'sinatra'
require 'rubygems'
root = ::File.dirname(__FILE__)
require ::File.join( root, 'application' )
set :environment, :development
set :root, root
set :app_file, File.join(root, 'application.rb')
disable :run
configure :development do
enable :logging, :dump_errors, :raise_errors
end
set :show_exceptions, true if development?
run Application.new
app.rb:
class App < Sinatra::Base
logger = ::File.open("log/development.log", "a+")
STDOUT.reopen(logger)
STDERR.reopen(logger)
Application.use Rack::CommonLogger, logger
end
Currently, I am able to get general logs, but I don't need general logs. I need to be able to see either in the web browser, or in a log, the server (500) errors that I'm receiving. Any help is appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将启用
:logging, :dump_errors, :raise_errors, :show_exceptions
移至我的 app.rb 中,事情似乎从那里开始起作用。Moved enable
:logging, :dump_errors, :raise_errors, :show_exceptions
into my app.rb and things seem to have worked from there.