Logging in Rails

Hi     I dont know much about logging in rails? Could anybody please explain how to do that in a live application? Or point me to any latest links which gives a detailed description of how to do this for different environments in rails? Why I am asking this is, I don't know where to start. But have a vague idea about the levels info,debug, etc. But dont know how to apply that (Or use it) in my application which is in an initial stage.Please help

Thanks in advance Tom

Have a look at the rails guide on debugging at http://guides.rubyonrails.org/. This has information on using the logger and other debugging techniques.


Also take a look at Ruby’s Logger documentation http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc/

Hi    Thanks for all reply. When googling I saw this


    Since a beginner I am asking what will be the advantage if using above? And also I would like to know what are the latest happenings like this

Thanks Tom

When starting with something new (Rails in this case) I suggest starting with the built in tools, when you are familiar with those then you can start looking round at other stuff that may or may not provide further useful features.


Hi Colin

     Thanks for replying back. One more thing I need to clarify is when to use the different levels for logging? For example say in controller we can write logger.info "some thing" or logger.warn "something"        How can we know that we should chose this here say info or warn here? Is there any criteria for this? My question may be blunder please excuse. Could you please pont to a good example?


If, in your application you are expecting value_a but it’s either nil or you have another value, that could be logger.error (if it’s critical to the continuation of the application) or if you can work around it but want to be notified about it to sort it out in the future it could be logger.warn,

logger.info could be “I’m here #{value_a}”

Anyway, it’s up to you to decide what is a warning and what is an error.

I just googled this for you …


I’m always use debug in development because that’s why I use it for, debug my app, better yet, change the default logger of Rails in your environment to point to STDERR and you’ll see your debug messages in the server shell

via guides.rubyonrails.org ActiveRecord::Base.logger = Logger.new(STDERR)