Create syslog compatible /dev/log socket
dinit could support collecting logging from programs which know how to only use syslog to log. Programs like postfix support logging to stdout but they gained this support recently, so for old versions they require syslog log collection. Moreover, postfix has a limitation that some logging might still happen to syslog:
Non-daemon Postfix programs will log errors to syslogd(8) before they have processed command-line options and main.cf parameters.
dinit could create a /dev/log
socket and read from it and output logs assigned to corresponding services. It could make it look like they are coming from service's stdout. Written messages are standardized in RFC 3164 and RFC 5424 and are generally in the format <30>Oct 12 12:49:06 host app[12345]: syslog msg
, for local messages host
might be missing.
There are some Go libraries which could help:
- https://pkg.go.dev/log/syslog
- https://pkg.go.dev/github.com/influxdata/go-syslog/v3
- https://pkg.go.dev/github.com/ziutek/syslog
- https://pkg.go.dev/gopkg.in/mcuadros/go-syslog.v2
- https://pkg.go.dev/github.com/jeromer/syslogparse
The question is how to support post-processing log messages further? So we could parse standard syslog messages into JSON, but what if user wants to parse message payload itself further into JSON? Should we support additional sub-process? Named syslog
maybe to process those? Maybe just pretending messages are coming from stdout of the main process and writing them to log
process might be also an option? Probably just writing them as text lines as they are written to syslog (and multiplexing with the rest which is written to log stdin if it exists). I think that is the best. Just how to make route messages to which program/service is still unclear.
Supporting both /dev/log and stdout logging being both used together could then make dinit be able to support in the same way both old and new versions of programs (example is postfix, where conversion to JSON is possible only in newer versions which uses stdout).
Sympa also supports only syslog.
The problem of using rsyslog or some other daemon to collect syslog logging from programs managed by dinit is that logrotation does not work because existing configuration files for triggering reopening logs do not know about dinit (and dinit does not even expose way to do that).