If you use Sinatra 1.3, you can log in the same way as in rails using logger.info
Copied from Sinatra Readme :
entrance
In the request area, the log assistant detects a Logger instance:
get '/' do logger.info "loading data" # ... end
This logger automatically takes into account rack account management settings. If logging is disabled, this method will return a dummy object, so you don’t have to worry about your routes and filters.
Note that logging is only allowed for Sinatra :: Application by default, so if you inherit from Sinatra :: Base, you probably want to enable it yourself:
class MyApp < Sinatra::Base configure :production, :development do enable :logging end end
To avoid installing middleware, set the logging parameter to nil. However, keep in mind that the registrar in this case returns zero. A common use case is when you want to set up your own registrar. Sinatra will use whatever it finds in env ['rack.logger'].
Rack :: CommonLogger creates log messages inside (I think).
source share