Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging via UNIX domains sockets is not quite conformant #154

Open
indyjo opened this issue Aug 13, 2021 · 0 comments
Open

Logging via UNIX domains sockets is not quite conformant #154

indyjo opened this issue Aug 13, 2021 · 0 comments

Comments

@indyjo
Copy link

indyjo commented Aug 13, 2021

The messages sent to /dev/log via UNIX domain sockets by winston-syslog are formatted according to RFC 3164 by default. However, Syslog daemons listening on /dev/log apparently expect a slightly different format. In the expected format, the HOSTNAME field (specified by RFC 3164 to immediately follow the TIMESTAMP) does not occur.

When using winston-syslog to log to systemd's journald on /dev/log, this results in the log message not being parsed correctly. Specifically, the property SYSLOG_IDENTIFIER is not extracted correctly which makes filtering harder.

As a workaround, I recommend setting the localhost option to an empty string:

new winston.transports.Syslog({
  protocol: "unix",
  path: "/dev/log",
  facility: "local0",
  localhost: "", 
  app_name: "my-app",
  level: requestedLevel,
  format: syslogFormat
})

I couldn't find this behavior of /dev/log specified anywhere, but source code of journald, glibc and musl all point into the same direction, and there is this discussion:

Oh, P.S.: /dev/log isn't RFC3164, it's RFC3164 without the hostname field (and without a trailing \n) - sending RFC3164 doesn't work 😄
Originally posted by @eqvinox in systemd/systemd#19251 (comment)

Ideally, winston-syslog would automatically configure a different message format (modified BSD/RFC 3164) when protocol "unix" is selected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant