1

I'm using Python 3.7. I want to log to a remote rsyslog server using RFC-5424 over UDP. The problem is, logging.handlers.SysLogHandler is producing what looks like the old RFC-3164 format:

<14>2022-05-29 14:40:08,746 [none] INFO spi.views.foo: hello

I see a couple of third-party packages (rfc5424-logging-handler and syslog-rfc5424-formatter) that generate 5424 format but given that RFC-5424 has been around for 13 years, it is surprising that there's no native way to do this. Am I missing something obvious, or do I really need to load an external package?

Roy Smith
  • 2,039
  • 3
  • 20
  • 27
  • 1
    The mere existence of an RFC doesn't mean anybody is using it. I haven't seen wide adoption of RFC5424 anywhere, so it's not surprising to find support lacking in Python's `logging` module. Apparently nobody has found it important enough to contribute the support (or possibly the existing 3rd party modules work well enough that there's no motivation for Yet Another Implementation). – larsks May 29 '22 at 15:22
  • 1
    As @larsks said, RFC5424 isn't used often - RFC3164 still is the standard format in most syslog loggers. You can [create a template](https://stackoverflow.com/a/72390927/7558856) for rsyslog, to create RFC5424 compliant logs. – eDonkey May 30 '22 at 09:26

1 Answers1

0

OK, so it looks like the answer really is that the standard library doesn't support RFC-5424, despite the fact that the docs for SysLogHander.emit() makes a vague mention of it.

I ended up going with syslog-rfc5424-formatter, mostly because it had more users. It seems to work fine.

Roy Smith
  • 2,039
  • 3
  • 20
  • 27