SysLogHandler message formatting

Dustin C. Hatch admiralnemo at
Fri Oct 8 16:46:25 CEST 2010

On Oct 7, 6:18 am, Vinay Sajip <vinay_sa... at> wrote:

> Thanks for the detailed report. I tried posting a response a couple of times,
> but Google appears to have swallowed it ... trying again. Sorry if it results in
> multiple responses.
I tried to respond yesterday, but I also noticed this probelm.

> The SysLogHandler aims to work within RFC 5424, though that does provide for
> some flexibility in message formats. The SysLogHandler sends <priority>formatted
> message, as you've observed, with the "formatted message" part encoded in UTF-8
> with a prepended BOM if it's Unicode.
I started to read RFC 5424 yesterday before posting this, but it
seemed to describe a much more complex message format than
SysLogHandler was producing, so I wasn't sure if that was the
reference or not. I may go back and read it completely, now that I
know, though.

> The existing SysLogHandler code seems to work OK with syslog, syslog-ng and
> rsyslog
I agree with this, so I would normally assume that Metalog is the
problem and simply stop using it. Unfortunately, I have several
systems that use Metalog, and I don't want to introduce any
inconsistencies by having one use something else. Switching them all
would also be a hassle.

> - perhaps these are more forgiving than Metalog in the way they parse
> messages, or perhaps it's a Metalog configuration issue. I'd try posting this
> issue to the Metalog forum / mailing list to see what feedback they can give.
I will do that; I just wanted to see what the Python stance was first.
I will keep you apprised of anything determined through that route.

> If you do think it's a bug in SysLogHandler then please create an issue on
> and assign it to me, so I can take a look at it
After I communicate with the Metalog community, I will definitely file
an issue if necessary. I didn't want to jump the gun, though.

> I think using an appropriate Formatter will ensure interoperability in any
> particular scenario. I don't especially want to hard-code any format into
> SysLogHandler, since a Formatter can be used to set the format flexibly.
I think the only problem with doing it that way is that I wasn't
initially aware that using a Formatter affected how the message is
sent to Syslog, but assumed it only modified the visible portion. I
will admit that, until yesterday, I knew nothing of the syslog
protocol. Perhaps the best solution would be to simply document the
fact that adjusting the message format can affect how the message is
parsed by the syslog daemon receiving it.

Thank you for your feedback.

More information about the Python-list mailing list