logging icon indicating copy to clipboard operation
logging copied to clipboard

UDP appender

Open petemounce opened this issue 12 years ago • 2 comments

Would a UDP appender be possible?

We use statsd for our metrics collection endpoint, which wants UDP packets containing strings like dotted.bucket.name:value|bucket-type and I'd like to use logging to push messages.

Also, while I think about it - is it possible to transform messages? So when writing to appender A, it would apply a transform to the message (in this case, probably discard the English text and do something like transform the class into a dot-separated string, glue the log-level on the end, and maybe parse a value out of the message itself).

petemounce avatar Dec 04 '12 13:12 petemounce

A UDP appender is definitely possible. With an appender, you give it a Layout object that will format messages however you desire. Take a look at the basic layout to get a feel for how they work. But you can go hog wild with layouts to get messages into the format you need.

The approach I would take for a UDP appender is to wrap a statsd Ruby gem with an appender. So all the heavy lifting would be done by the gem, and your appender would simply call methods provided by the library (I have not looked to see if a statsd gem is available).

TwP avatar Dec 30 '12 04:12 TwP

Part of this may be possible with the existing IO appender and remote_syslog_logger. It was written for Papertrail so it uses syslog framing, but has the guts of a UDP transmitter in RemoteSyslogLogger::UdpSender. I think with an additional alias_method :syswrite, :transmit, a RemoteSyslogLogger could be passed to the existing IO appender. Worst case it's an example.

troy avatar Apr 06 '13 17:04 troy