# Logging errors with Rails logger

**URL:** <https://www.ruby-forum.com/t/logging-errors-with-rails-logger/173940>\
**Category:** Rails\
**Created:** [August 18, 2009, 3:32pm UTC](https://www.ruby-forum.com/t/logging-errors-with-rails-logger/173940 "2009-08-18T15:32:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pyr0](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/da6949/32.png) [@pyr0](https://www.ruby-forum.com/u/pyr0)\
**Post date:** [August 18, 2009, 3:32pm UTC](https://www.ruby-forum.com/t/logging-errors-with-rails-logger/173940/1 "2009-08-18T15:32:29Z")

</div>

Coming from the java log4j world, the default logging functionality in  
rails seems a bit primitive to me, but it might have to do with my  
lack of knowledge on the subject. Currently I would log an exception  
like:

```
 begin
   //some code
 rescue Net::IMAP::ResponseError => exc
   Rails.logger.error("IMAP error for event #{@event.inspect}:\n

```

#{exc.message}\n#{exc.backtrace.join("\n")}")  
end

The above code gets the job done in that i get a decently formated  
backtrace with an error message, but it is obviously not ideal. Also,  
my log file is missing valuable meta-data like time and the class  
which logged the message. Is there something I am missing?

thx.

-karl
