syslog: headers, priorities and kernel events
/var/log/messages and /var/log/syslog mix everything the machine has to say: daemons, cron, systemd, the kernel. During an incident the useful lines are a handful among thousands โ an OOM kill, a disk I/O error, a service that exited.
Drop the file on this page and the board shows the busiest programs, kernel and system events (OOM kills, segfaults, I/O errors, link up/down, time sync) on a timeline, and calls out OOM kills and disk I/O errors by host and device. The one-liners below do the same on the server.
Two header formats
RFC 3164 (BSD syslog)
The older, informational format, still what most files on disk look like:
<34>Oct 11 22:14:15 mymachine su: 'su root' failed for lonvick on /dev/pts/8| Part | In the example | Rules |
|---|---|---|
| PRI | <34> | Facility ร 8 + severity, in angle brackets. Text files written by the local syslog daemon usually leave it out. |
| TIMESTAMP | Oct 11 22:14:15 | "Mmm dd hh:mm:ss", local time, 24-hour clock. No year, no time zone. Days below 10 are padded with a space: "Oct 7" has two spaces. |
| HOSTNAME | mymachine | Host name, IPv4 or IPv6 address of the sender. |
| TAG | su | Program name, up to 32 alphanumeric characters; any other character ends it and starts CONTENT โ so the colon after su already belongs to CONTENT. A process id in brackets, as in sshd[3011]:, is common. |
| CONTENT | 'su root' failed โฆ | Free text. |
Because the day can be one or two characters with padding, awk field numbers stay the same ($1 month, $2 day, $3 time, $4 host, $5 tag) but fixed character positions do not line up for days 1โ9 unless you account for the padding. The missing year matters when a file spans New Year.
RFC 5424
The current standard adds a version, a full timestamp and structured data:
<165>1 2026-10-18T10:02:11.003Z web-1 app 4242 ID47 [exampleSDID@32473 iut="3"] request timed out| Field | In the example | Rules |
|---|---|---|
| PRI | <165> | Same calculation. 165 = facility 20 (local4) ร 8 + severity 5 (notice). |
| VERSION | 1 | Protocol version. |
| TIMESTAMP | 2026-10-18T10:02:11.003Z | Full date and time with fractions and a zone, or "-". |
| HOSTNAME | web-1 | Up to 255 characters, or "-". |
| APP-NAME | app | Up to 48 characters, or "-". |
| PROCID | 4242 | Up to 128 characters, or "-". |
| MSGID | ID47 | Up to 32 characters, or "-". |
| STRUCTURED-DATA | [exampleSDID@32473 iut="3"] | Zero or more [id name="value"] elements, or "-". |
| MSG | request timed out | The message. |
Facility and severity
PRI packs two numbers: PRI = facility ร 8 + severity. So facility is int(PRI / 8) and severity is PRI % 8. <0> is kern.emerg; <165> is local4.notice.
| Severity | Name |
|---|---|
| 0 | Emergency: system is unusable |
| 1 | Alert: action must be taken immediately |
| 2 | Critical |
| 3 | Error |
| 4 | Warning |
| 5 | Notice: normal but significant |
| 6 | Informational |
| 7 | Debug |
| Facility | Name |
|---|---|
| 0 | kernel messages |
| 1 | user-level |
| 2 | |
| 3 | system daemons |
| 4 | security/authorization |
| 5 | syslogd internal |
| 6 | line printer |
| 7 | network news |
| 8 | UUCP |
| 9 | clock daemon |
| 10 | security/authorization |
| 11 | FTP daemon |
| 12 | NTP |
| 13 | log audit |
| 14 | log alert |
| 15 | clock daemon |
| 16โ23 | local0 โ local7 |
Kernel and system events worth finding
The OOM killer writes two lines that matter: which task triggered it and which process it killed. From the kernel source (6.x):
Oct 18 10:02:11 web-1 kernel: java invoked oom-killer: gfp_mask=0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), order=0, oom_score_adj=0
Oct 18 10:02:11 web-1 kernel: Out of memory: Killed process 4242 (java) total-vm:8123456kB, anon-rss:6012344kB, file-rss:0kB, shmem-rss:0kB, UID:1001 pgtables:12345kB oom_score_adj:0
Oct 18 10:02:12 web-1 systemd[1]: app.service: Main process exited, code=killed, status=9/KILL<task> invoked oom-killer:โ the task whose memory allocation failed. Not necessarily the one killed.Out of memory: Killed process <pid> (<name>)โ the victim, with its virtual size and resident memory (anon-rss, file-rss, shmem-rss) at that moment. When the limit was a cgroup, the text begins with "Memory cgroup out of memory" instead.- The next lines are usually the service manager noticing:
code=killed, status=9/KILLfrom systemd is the same event seen from the service side.
Other lines worth a timeline: segmentation faults (segfault at), block I/O errors (I/O error, dev sdb), file system errors, and NIC link changes. Their exact wording depends on the kernel version and driver, so search with a short, case-insensitive pattern rather than a full sentence.
Shell one-liners for syslog files
Run against a sample /var/log/messages in RFC 3164 style (no PRI) and a small RFC 5424 file. On systemd hosts, journalctl -k gives kernel messages and journalctl -o short prints lines in the same layout, so the same pipes work.
Which programs write the most lines (pid stripped).
awk '{print $5}' messages | sed -E 's/\[[0-9]+\]//; s/:$//' | sort | uniq -c | sort -rn | headLines per host, when several servers log to one file.
awk '{print $4}' messages | sort | uniq -c | sort -rnHow many processes the OOM killer killed.
grep -cE '(Out of memory|Memory cgroup out of memory): Killed process' messagesWhich process names were killed.
grep -oE 'Killed process [0-9]+ \([^)]+\)' messages | awk '{print $4}' | tr -d '()' | sort | uniq -c | sort -rnWhich tasks triggered the OOM killer.
grep -oE '[^ ]+ invoked oom-killer' messages | sort | uniq -cWhich programs crashed with a segfault.
grep -oE '[^ ]+\[[0-9]+\]: segfault at' messages | cut -d[ -f1 | sort | uniq -c | sort -rnHow many lines mention an I/O error.
grep -ciE 'i/o error' messagesLines per minute โ bursts stand out.
cut -c1-12 messages | uniq -cLines per host per hour.
awk '{split($3, t, ":"); print $4, t[1] ":00"}' messages | sort | uniq -cWhich programs write lines with error, fail or timed out.
grep -iE 'error|fail|timed out' messages | awk '{print $5}' | sed -E 's/\[[0-9]+\]//; s/:$//' | sort | uniq -c | sort -rnRFC 5424: decode PRI into facility and severity.
grep -oE '^<[0-9]+>' syslog5424.log | tr -d '<>' | awk '{print "facility", int($1/8), "severity", $1%8}' | sort | uniq -cRFC 5424: lines per host and app name.
awk '{print $3, $4}' syslog5424.log | sort | uniq -c | sort -rn
FAQ
What is the difference between RFC 3164 and RFC 5424?
RFC 3164 describes the older BSD format: PRI, a timestamp without year or zone, host and a free-form tag. RFC 5424 is the standard that replaced it: a version number, a full ISO-style timestamp with zone, separate app name, process id and message id fields, and structured data.
How do I get facility and severity from the PRI number?
Facility is the integer part of PRI divided by 8; severity is the remainder. <34> is facility 4 (security/authorization), severity 2 (critical).
Why is there no year in /var/log/messages?
The RFC 3164 timestamp format has none. Tools assume the current year, which goes wrong for files that cross New Year. RFC 5424 timestamps carry the year and zone.
How do I find what the OOM killer killed?
Search for "Out of memory: Killed process". The pid and process name follow, then its memory at the time. The line before it says which task invoked the OOM killer.
Why is the day sometimes followed by two spaces?
RFC 3164 pads days below 10 with a space, so "Oct 7" has two spaces. awk splits on runs of spaces and is not affected; cut -d" " is.
Can it read journald output?
Text exported with journalctl in the default short format has the same layout as a syslog file and can be dropped on the board. JSON export is read as JSON lines.