papertrail / remote_syslog_logger

Ruby Logger that sends directly to a remote syslog endpoint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for TaggedLogging

nachokb opened this issue · comments

Rails 3+ supports adding per-request tags to log entries (particularly useful for logging requests' uuid). RSL just ignores them, it seems.

I second this! 👍

I spent a chunk of today trying to figure out why my :uuid wasn't being logged. After chatting with Leon, I realized that it wasn't supported by RemoteSyslogLogger.

Without this, I think that I'm going to have to write Rack middleware to grab the X-Request-Id header and a custom logger formatter (I'm assuming that this is possible) to display it along with every log entry. I'd love to just be able to use this Rails feature. :)

Keep in mind that this class is a Ruby Logger implementation, and no part of it is Rails-specific or Rails-aware.

As far as using tagged logs, it looks like ActiveSupport::TaggedLogging can be passed any Logger-compatible class. Are you able to instantiate TaggedLogging and back it with this class, like this? For example, in a Rails initializer:

logger = ActiveSupport::TaggedLogging.new(RemoteSyslogLogger.new(STDOUT))

While I haven't tried that, it seems like it should work and like it's the roles that TL and RSL were each meant to play.

Thanks @troy. I'll take a look...

I can confirm that the workaround suggested by @troy works. Thanks!