Skip to content
Tutorials Center
My learning

Topics

Linux Command Reference ยท Systemd and Logging (Read-Only)

Log priorities (severity levels)

The eight syslog severity levels from emerg (0) to debug (7), how journalctl -p, logger -p and rsyslog selectors use them, and which level to choose when logging.

Every syslog and journal message carries a priority, a number from 0 to 7 that says how serious it is. The scale is shared by the kernel, syslog, logger, journalctl, rsyslog and libraries such as syslog(3). Lower numbers are more severe, which surprises many people: priority 0 is a catastrophe and 7 is debugging chatter.

When you filter by priority you select a threshold: journalctl -p warning shows warning (4) and everything more severe (3, 2, 1, 0). You can run the real commands only against a live journal, so those are read-only here, but the examples work with the numbers and with logger's level names.

Terminal
journalctl -p err -b
logger -p user.warning "disk 90% full"
dmesg --level=err,warn

Try it

Bash The eight levels

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash A priority is a threshold (sample log)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
journalctl -p LEVEL            # LEVEL or LEVEL..LEVEL; name or number
logger -p FACILITY.LEVEL "message"
dmesg --level=LIST             # kernel messages
printk: <3>kernel message      # the kernel's own prefix notation
Number Name Typical use
0 emerg The system is unusable; kernel panic. Broadcast to all terminals by many configurations.
1 alert A human must act at once, for example the main database is corrupt.
2 crit Critical failures: hardware errors, a service's core function lost.
3 err Errors: an operation failed but the service continues.
4 warning Something unexpected that may become a problem.
5 notice Normal but noteworthy events: a service started, a configuration reloaded.
6 info Routine progress information.
7 debug Detail useful only when developing or diagnosing.

Returns: journalctl -p err is shorthand for -p 3; the accepted aliases are emerg, alert, crit, err, warning, notice, info, debug (and the old synonyms error, warn, panic in logger).

Errors and edge cases: the numeric value is not the same as the syslog PRI header, which combines facility and level as facility * 8 + level (for example auth.err = 4 * 8 + 3 = 35).

Usage notes

  • Lower is worse. -p 3 includes 0, 1 and 2. To see only exactly one level in journalctl use a range such as -p 4..4.
  • Pick the level by who must react, not by how you feel: err means somebody should look soon, warning means watch it, notice and info are for the record.
  • Default thresholds hide debug. Most services log info and above in production; debug is switched on per service, often with a flag or SYSLOG_LEVEL.
  • Kernel log level (/proc/sys/kernel/printk) controls which kernel messages reach the console; dmesg still shows all of them. See The /proc and /sys filesystems.
  • Do not log secrets at any level, and avoid debug output in production services that handle personal data.
  • systemd services can set SyslogLevel= and LogLevelMax=; lines printed with a <N> prefix on stdout (for example <4>cache low) are logged at that priority.
  • Alerting rules usually trigger on err or worse; counting them with journalctl -p err --since today | wc -l is a quick health check.