views:

113

answers:

3

I am looking for the best way to customize my Rails log entries (I want to add the user ID in there). I am using Rails 2.1.2. The only way I've found so far is to override method "add" of class BufferedLogger (as defined in active_support/lib/active_support).

But it ain't pretty: I have to copy all the code in there and it is closely tied to the current implementation. Is there a better way? I found this on the Google: http://pandejo.blogspot.com/2007/08/customize-logger-message-format.html but it seems outdated. One day, I might create a specific audit log, but it is overkill for what I need: http://maintainable.com/articles/rails_logging_tips#audit-logs Cheers.

A: 

What are you trying to capture, every action each user does, or just a specific sub-set of actions? If a sub-set one quick and dirty way would be to simply use a logger call to dump the user-id to the log for the actions you want to track.

Glenn
take a look here: http://railsforum.com/viewtopic.php?id=23540, to build a custom logger with it's own log file.
that link points to the same link as in the original question. "overkill" for now.
Glenn
+1  A: 

Have you seen the user_event_logger plugin?

Mike Breen