# Hook Exist in Rails for System-Wide Exception Logging?

**URL:** <https://www.ruby-forum.com/t/hook-exist-in-rails-for-system-wide-exception-logging/160323>\
**Category:** Rails\
**Created:** [February 14, 2009, 2:29pm UTC](https://www.ruby-forum.com/t/hook-exist-in-rails-for-system-wide-exception-logging/160323 "2009-02-14T14:29:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [February 14, 2009, 2:29pm UTC](https://www.ruby-forum.com/t/hook-exist-in-rails-for-system-wide-exception-logging/160323/1 "2009-02-14T14:29:03Z")

</div>

On our production servers, I’d like all exceptions to be automatically  
logged to the database.

In other C# project I wrote that meant putting a try/catch in every  
entry point method with the catch calling a generic routine which did  
the INSERT into exceptions… SQL statement.

How do I do this in rails? It would be nice if in application.rb or  
even in each controller you could do:

exception\_logger :my\_exception\_logger

Perhaps this could be implemented using filters? Hopefully rails  
already has this exact functionality built-in as I’d imagine everyone  
would need it?

Pete

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [February 16, 2009, 6:15am UTC](https://www.ruby-forum.com/t/hook-exist-in-rails-for-system-wide-exception-logging/160323/2 "2009-02-16T06:15:29Z")

</div>

Rails Exception Notifier will give you what you need. If you want, you  
can hook into it a write to the DB, but you will find that the email  
notification is plenty.

> **[GitHub - rails/exception\_notification: NOTICE: official repository moved to...](https://github.com/rails/exception_notification/tree/master)**
>
> master

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [February 16, 2009, 6:42am UTC](https://www.ruby-forum.com/t/hook-exist-in-rails-for-system-wide-exception-logging/160323/3 "2009-02-16T06:42:22Z")

</div>

[http://getexceptional.com](http://getexceptional.com) is pretty good for that kind of thing too.
