Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sinatra Logging & Stack Traces

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!

like image 480
al3xnull Avatar asked Nov 18 '25 23:11

al3xnull


1 Answers

Moved enable :logging, :dump_errors, :raise_errors, :show_exceptions into my app.rb and things seem to have worked from there.

like image 68
al3xnull Avatar answered Nov 21 '25 18:11

al3xnull



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!