Syslog: Complete System Administrator Guide
devconnected.com
devconnected.com
RFC 5424 defines a more formal and more complete version of the protocol. NetBSD understands and emits it, FreeBSD is still in the process of gaining support for it and OpenBSD seems to be perfectly content sticking to traditional BSD syslog as recorded in RFC 3164.
It's also worth mentioning that newlines are significant in TCP syslog (for batching log messages) but not in UDP syslog (because of frame size limits)
More because of the D in UDP, I believe. UDP is a packet (datagram) protocol; TCP is a stream protocol.
totally agree these exist and may vary wildly - many of these are often proprietary forks of the BSD version in some level of (un)maintained state, FWIW
sudo journalctl -o json -f | jq .
Thanks!
If configured to forward messages to syslog, I think systemd does so via the /run/systemd/journal/syslog socket, which is part of syslog.socket. But I believe rsyslog will these days read messages directly out of the journal rather than relying on journald to forward them.
Note that journald internally uses the this socket both for receiving syslog messages, and for forwarding them to any other syslog
edit: formatting
It seems like simply concating the facility and severity level would give a much more intuitive at a glance understanding of what's going on, and make it easier to awk all, say, emergency severity levels since they'd all end in 0, or awk for all cron facilities, as they would start with 09, or all FTP errors (FTP facility 11 + error 3, 113). Range would be 000 (for kernel, emergency) to 237 (for local 23, debug). Of course, I don't know anything about syslogs except what I learned in this article, so maybe this is totally off base.
In term of readability, it becomes clear if you use octal and not decimal representation: the last digit is security level whereas the others are facility number.
A bit to my surprise, the textual representation also uses that for the ‘on the wire’ protocol (and that isn’t to keep the format a text format. The ‘MSG’ part of a syslog message can (but SHOULD NOT) contain arbitrary byte sequences (https://tools.ietf.org/html/rfc5424#section-6.4). I would have expected this to be packed in a single byte there.
So, we have potentially binary messages, _and_ a syslog parser must know quite a bit of Unicode. Fun :-)
Regarding the second point, I believe the 7 is so ranges don't overlap. So for example facility X, severity 7 doesn't equal facility X + 1, severity 0.
That's the wire protocol, right? When rendered, this might show up as "2019-08-05T08:12:22Z <4.3> hostname ..."
I think it may be the other way around: with severity going up to 7, the multiplication factor was chosen to be 8.
The formula is like that because there are 3 bits of information in the Severity Level field: it has 8 values (0->7), and 2^3 = 8.
Multiplying the Facility Number by 8 (or, equivalently, by 2^3 or by left shifting the number by 3), frees up the bottom 3 bits.
This is the same operation as you are suggesting to do in base-10: multiply by 10^3 to free up the bottom 3 digits, but for base-2 (i.e. in binary).
When the Facility Number has been moved out of the bottom 3 bits you can add in the Severity Level and get a combined value for both.
It's true that it's not very intuitive when they then render the resulting number in base-10 / decimal, however, it does get you the most compact encoding given the size of the two fields.
As another poster says, if the number had been rendered in octal (base-8) then the Severity Level would be the right-most number in the series.
You'd have something like filebeat or fluentd reading the logs locally and then shipping via that protocol to a central system where they'd be ingested. For application logging, definitely use structured data (like JSON, for example) over log-lines. It's easier to parse in the long-run.
1: https://en.wikipedia.org/wiki/Reliable_Event_Logging_Protoco...