Make RoR log to database in addition to production.log

Folks,

Crawling through my production.log file is a pain. Is there any way I can have rails log all this information to a database table, instead of, or in addition to the production.log file? Ideally the DB table would have separate columns for some of the log details, like IP address, controller, action, errors, trace, etc. The idea is that I could then filter the log data to quickly see hits on a particular action, or from a particular IP address, etc.

I know I could parse production.log and throw it in the database, but I'd prefer to have that done up front without the need for a log parser.

Thanks

Thanks Alex, that's a helpful start.

So I could log the basics this way, but what about in the event of a Rails error? I imagine the after_filter wouldn't even be executed, no?

Joseph

Have you thought of using something like, google analytics, splunk or the rails log analyzer?

Have you thought of using something like, google analytics, splunk or the rails log analyzer?

I’m doing this in one of my apps…

I have a method in my application helper that displays the number of hits (ya, i know, old school hit counter, but what client wants, client gets). So, anyway, in addition to keeping up with the current hit count, I log the header data to the db.