# Logging in Rails

**URL:** <https://www.ruby-forum.com/t/logging-in-rails/185219>\
**Category:** Rails\
**Created:** [March 16, 2010, 10:03am UTC](https://www.ruby-forum.com/t/logging-in-rails/185219 "2010-03-16T10:03:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [March 16, 2010, 10:03am UTC](https://www.ruby-forum.com/t/logging-in-rails/185219/1 "2010-03-16T10:03:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [March 16, 2010, 10:46am UTC](https://www.ruby-forum.com/t/logging-in-rails/185219/2 "2010-03-16T10:46:17Z")

</div>

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

anl

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [March 16, 2010, 11:44am UTC](https://www.ruby-forum.com/t/logging-in-rails/185219/3 "2010-03-16T11:44:15Z")

</div>

Hi  
Thanks for all reply. When googling I saw this

[http://toolmantim.com/thoughts/logging\_rails\_to\_syslog\_with\_sysloglogger](http://toolmantim.com/thoughts/logging_rails_to_syslog_with_sysloglogger)

```
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

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [March 16, 2010, 10:24am UTC](https://www.ruby-forum.com/t/logging-in-rails/185219/4 "2010-03-16T10:24:37Z")

</div>

On 16 March 2010 09:03, Tom M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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

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

Colin

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [March 16, 2010, 11:58am UTC](https://www.ruby-forum.com/t/logging-in-rails/185219/5 "2010-03-16T11:58:52Z")

</div>

On 16 March 2010 10:44, Tom M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi  
> Thanks for all reply. When googling I saw this
> 
> [http://toolmantim.com/thoughts/logging\_rails\_to\_syslog\_with\_sysloglogger](http://toolmantim.com/thoughts/logging_rails_to_syslog_with_sysloglogger)
> 
> 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

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.

Colin

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [March 16, 2010, 12:03pm UTC](https://www.ruby-forum.com/t/logging-in-rails/185219/6 "2010-03-16T12:03:52Z")

</div>

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?

Tom

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [March 16, 2010, 12:21pm UTC](https://www.ruby-forum.com/t/logging-in-rails/185219/7 "2010-03-16T12:21:06Z")

</div>

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 …

[http://www.faqs.org/docs/evms/loglevels.html](http://www.faqs.org/docs/evms/loglevels.html)

On 16 March 2010 12:03, Tom M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Tom  
> For more options, visit this group at  
> [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–  
100% naturally selected. 0% designed.

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [March 16, 2010, 12:28pm UTC](https://www.ruby-forum.com/t/logging-in-rails/185219/8 "2010-03-16T12:28:08Z")

</div>

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](http://guides.rubyonrails.org)  
ActiveRecord::Base.logger = Logger.new(STDERR)

–  
anl

On Tue, Mar 16, 2010 at 12:19 PM, Anthony G.  
\<removed\_email\_address@domain.invalid
