Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7634771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:15:54+00:00 2026-05-31T07:15:54+00:00

I went through few blogs and sites which gave me some information about how

  • 0

I went through few blogs and sites which gave me some information about how to log in sinatra but didnt work for my app and also i went through a gem called sinatra-logger didnt tried it, wanted to know ideal and simple way to “log” in sinatra. Like we do logger.info for rails.

The code which i tried and didnt work is from the following site link and also some of SO links were too pointing to the same approach used in the link above.

configure do
 LOGGER = Logger.new("sinatra.log")
end

helpers do
 def logger
  LOGGER
 end
end

i have written this in app.rb of my app, it fails saying undefined method `configure’ for App:Module

Any pointers or guide would be helpful. Thanks.

Edits
Right Now am using file write to log my errors and messages:

File.open('log.txt', 'a') do |f|
 f.write "#{status}-#{CONFIG.api_url}-#{data.inspect}-tweet}"
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:15:55+00:00Added an answer on May 31, 2026 at 7:15 am

    If you are using Sinatra 1.3 you should be able to log just like in rails with logger.info

    The following is copied from the Sinatra Readme:


    Logging

    In the request scope, the logger helper exposes a Logger instance:

    get '/' do
      logger.info "loading data"
      # ...
    end
    

    This logger will automatically take your Rack handler’s logging settings into account. If logging is disabled, this method will return a dummy object, so you do not have to worry in your routes and filters about it.

    Note that logging is only enabled 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 any logging middleware to be set up, set the logging setting to nil. However, keep in mind that logger will in that case return nil. A common use case is when you want to set your own logger. Sinatra will use whatever it will find in env[‘rack.logger’].


    Rack::CommonLogger generates the log messages internally (I think).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I went through a few blogs/posts and there are some good solutions for input
Yes, I've read the developer documentation and even went through a few tutorials... but
I went through few post but didn't find an answer to probably one of
I went through a few basics on preg match but its quite difficult when
This is a newbie query. I went through few similar posts, but they are
i think this question was asked few times, which I have went through and
I went through some tutorials on the State monad and I think I got
I went through lots of searching the web which shows how to draw custom
I went through couple of articles that talk about Web Workers in HTML5 and
I have went through a few links here, not all of them, regarding MKPinAnnotationView

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.