-
Notifications
You must be signed in to change notification settings - Fork 572
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
Adding feature to allow zerolog to output SystemD compatible binary logs. #52
Comments
From what i read, journalD looks like a Key:Value logging mechanism - Key & Value are both strings. Sent to the systemD which will compress it and store it (log rotate it etc). There are methods to retrieve it / query it etc.. Any client of journalD will need to send a Priority + Message + (Key+Value) Pairs - over a unix socket to journalD or systemD. Is my understand right ?? If so, this will be another kind of writer - like consoleWriter.. instead of formatting the log message for printing to console - this journaldWriter will convert logs to journalD format (Prio + Msg + KV Pairs) and send it to systemd ?? CBOR (binary) encoding does not add much value to it - since the logs are to be converted to strings to be sent to journalD. |
My understanding is that journald fields is a flat structure with no typing support. We might just want to create a writer that would set the priority field and set the message field with the JSON payload. |
I have written a writer that will write to journald. I tested it by writing an example program. I could use some ideas on how to write a go-test to add tests. First cut diff: toravir@163f52c |
Fixed by #57 |
Note to the OP that the way you log to journald (redirecting stdout/stderr or using its socket) is not related to the logs being persistent. If you want journald logs to be persistent, you need to configure it so by setting the Storage option to |
The current behavior of zerlog binary output is to support
CBOR
encoding, however, with systemD emerging and being used in almost every Linux Distribution (Debian, CentOS, RHEL, SLES which are Distributions dedicated for enterprise/server consumption mainly).One could argue that it is beneficial to implement the journalD (logger service integrated with systemD) to allow persistent logging and even a concise way to log information across a server-stack.
The following links provide information about this feature request:
Two things to point out however, journalD binary files are highly corruptible and I personally do not favor them, however this is not about opinions, but providing the right tool for the general public.
The current STD logging in zerolog works perfectly fine when using
journalctl -u goservice.service
however, the logs are not persistent and lose all the data on restart/reboot of the system or service, thus the need for the "journaling" integration.Thank you, and Best of Luck!
The text was updated successfully, but these errors were encountered: