辛纳特拉测井与堆栈跟踪

发布于 2024-11-15 15:21:30 字数 825 浏览 1 评论 0原文

目前,我正在运行一个在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

好听的两个字的网名 2024-11-22 15:21:30

将启用 :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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文