The alert fires at 02:00. Your service retries a dependency for six minutes, then recovers. In the morning you run:

journalctl -u myapp.service --since "02:00" --until "02:10" 

You get forty lines, all from before the incident, and then a gap. The application's own counters say it logged thousands of errors. The journal says almost nothing.

The tempting conclusion is "logging is broken." Usually it is not. systemd-journald accepted the messages and then made a policy decision about them: keep, drop, or delete. If you do not know which policy applied, an empty query looks like proof of silence when it is really proof of filtering.

Every message that reaches the journal passes four gates:

  1. Storage — is the journal on disk, or only in memory?
  2. Rate limiting — did the service exceed its message budget?
  3. Level filtering — was the message below the configured maximum level?
  4. Retention — was the file already rotated or vacuumed away?

This is a practical tour of all four, with the settings that matter and the queries that answer "what actually happened."

Gate 1: The journal may not be on disk

The journal is not a text log. It is a set of binary files under /run/log/journal (volatile, lost at reboot) and /var/log/journal (persistent). Storage= in journald.conf chooses:

  • volatile — memory only, under /run/log/journal.
  • persistent — disk first, under /var/log/journal, falling back to /run during early boot.
  • auto — persistent if /var/log/journal already exists, otherwise volatile.
  • none — store nothing (forwarding to console, kmsg, or syslog can still work).

That auto rule is the one that surprises people. The directory is the switch. If it was never created, or if the image build removed it, you have a runtime-only journal and a reboot erases the evidence.

Check what you actually have:

journalctl --disk-usage ls -ld /var/log/journal journalctl --list-boots --no-pager | tail -3 

If /var/log/journal is missing and you want persistence:

sudo mkdir -p /var/log/journal sudo systemd-tmpfiles --create --prefix /var/log/journal sudo systemctl restart systemd-journald sudo journalctl --flush 

journalctl --flush asks the daemon to move anything already buffered in /run/log/journal to /var/log/journal. It is idempotent: the move happens once per boot, and later calls are a no-op. On a normal boot, systemd-journal-flush.service does this for you.

Two consequences worth remembering:

  • Per-user journals are not supported on volatile storage, so journalctl --user will not work.
  • Switching Storage= to volatile does not delete existing persistent files. It only stops new data going there.

If the logs must survive the host, this is also the point to forward them off-box. A local journal is a bounded cache, not a backup.

Gate 2: Rate limiting eats bursts

This is the gate that most often explains "the logs stop right when things got interesting."

The documented default is 10,000 messages per 30 seconds, per service. Cross the burst and journald drops the rest until the interval ends, then emits a notice about how many messages were dropped. The limit is applied per service, so one noisy unit does not silence its neighbours.

There is a detail in journald.conf(5) that sounds made up but is not: the effective burst is multiplied by a factor derived from the free space available to the journal, using the base-2 logarithm. Roughly:

  • up to 1 MB free: multiplier 1
  • up to 4 GB free: multiplier 4
  • up to 64 GB free: multiplier 5
  • up to 1 TB free: multiplier 6

In other words, a nearly full disk tightens the limit exactly when you are most likely to need the logs. Bounding the journal is necessary; assuming the bound never affects you is not.

Fix it per unit, not globally

For one chatty service, raise its budget in a drop-in:

# /etc/systemd/system/myapp.service.d/10-logging.conf [Service] LogRateLimitIntervalSec=30s LogRateLimitBurst=50000 

Apply and confirm:

sudo systemctl daemon-reload sudo systemctl restart myapp.service systemctl show -p LogRateLimitBurst -p LogRateLimitIntervalUSec myapp.service 

The unit-level values override the journal-wide defaults. If you set them explicitly, systemctl show echoes them back.

journald.conf documents that setting either rate-limit value to 0 disables rate limiting entirely. Do not do that globally to fix one service. A crash loop with no limit can fill the disk and take down more than your log pipeline. Raise the burst for the unit that needs it, and keep a disk budget in place (Gate 4).

One escape hatch is documented in systemd.exec(5): rate limiting only applies to messages processed by journald. If you connect a service's output directly to a file with StandardOutput=file:..., those lines bypass the limit. That is useful for a small number of must-keep records, but you lose field-based querying and centralized rotation. Choose deliberately.

Gate 3: Priority filters drop messages earlier

There are two separate level filters, and they run at different stages.

Per unit, early: LogLevelMax= in the service unit. Messages above the configured level are discarded before journald does further processing. The default is debug, so nothing is filtered unless you ask.

[Service] LogLevelMax=info 

That keeps emerg through info and drops debug. It is a good default for a service that thinks debug logging is a production feature.

Journal-wide, at storage: MaxLevelStore= in journald.conf. This controls what is written to disk. The default is debug. Setting it to info drops debug records even if a unit's own LogLevelMax allowed them.

The numbering is the part people misread. Syslog levels count down in importance: emerg is 0, err is 3, info is 6, debug is 7. A maximum level of info means "store everything at or below 6," which includes errors and excludes debug.

If a service is missing debug lines, check both layers before blaming the application:

systemctl show -p LogLevelMax myapp.service grep -RhE '^\s*MaxLevel(Store|Syslog|Console)=' /etc/systemd/journald.conf /etc/systemd/journald.conf.d 2>/dev/null 

Gate 4: Retention deletes by size, not by surprise

journald rotates and deletes its own files. It does not use logrotate, so a logrotate policy for /var/log/syslog tells you nothing about journal retention.

The important defaults:

  • SystemMaxUse= — 10% of the filesystem, capped at 4 GB.
  • SystemKeepFree= — 15% of the filesystem.
  • SystemMaxFileSize= — one eighth of SystemMaxUse, capped at 128 MB.
  • MaxFileSec= — one month per file.
  • MaxRetentionSec= — 0, meaning time-based deletion is off.

journald respects both the "use at most" and "keep free" limits and picks the smaller allowance. When it needs space, it deletes archived files. Active files are left alone. This produces a result that looks like a bug:

sudo journalctl --vacuum-size=500M journalctl --disk-usage 

The second command can still report more than 500 MB, because --disk-usage counts active plus archived files, while vacuuming only removes archived ones. To make vacuuming see everything currently written, rotate first:

sudo journalctl --rotate --vacuum-size=1G journalctl --disk-usage 

--rotate marks the active files as archived and opens fresh ones; the vacuum then has the full set to work with. The same logic applies to --vacuum-files=: it will not delete active files, so the final count can remain higher than requested.

Set an explicit budget instead of relying on percentages:

# /etc/systemd/journald.conf.d/10-retention.conf [Journal] SystemMaxUse=2G SystemKeepFree=5G SystemMaxFileSize=128M MaxFileSec=1month MaxRetentionSec=3month 
sudo systemctl restart systemd-journald 

Size limits are enforced as files grow, so the cap takes effect without waiting for a timer. Time-based retention is applied as files rotate.

Stop grepping a binary log: query by field

Because the journal is structured, you rarely need to grep the message text. Every record carries fields such as _SYSTEMD_UNIT, _PID, _UID, _COMM, _EXE, _TRANSPORT, PRIORITY, and SYSLOG_IDENTIFIER.

See one record in full:

journalctl -o json-pretty -n 1 --no-pager 

Useful queries:

# Errors and worse for one unit, current boot journalctl -u myapp.service -b -p err --since "1 hour ago" --no-pager # The previous boot journalctl -b -1 -u myapp.service --no-pager # Exact field match (different fields are ANDed) journalctl _SYSTEMD_UNIT=myapp.service PRIORITY=3 --no-pager # PCRE2 search; an all-lowercase pattern is case-insensitive journalctl -g 'timeout|connection refused' --no-pager # What units and fields exist? journalctl -F _SYSTEMD_UNIT | sort -u | head -20 journalctl -N | sort # Kernel messages only journalctl -k -b --no-pager 

A few semantics that save time:

  • -p err means err and more important (emerg, alert, crit, err), not only err.
  • Multiple matches on different fields are ANDed. Multiple values for the same field are ORed. A literal + between terms creates an OR group.
  • -g uses PCRE2, not basic grep syntax. If the pattern is all lowercase, matching is case-insensitive; use --case-sensitive to override.
  • -u filters records attributed to that unit. A helper process that logs under a different unit, or under no unit at all, will not match. Try -t myapp (matches SYSLOG_IDENTIFIER) or _COMM=myapp in that case.
  • -o cat prints only the message; -o json is the format to pipe into jq.

Access is its own gate. The system journal is readable by root and by members of systemd-journal, adm, or wheel:

sudo usermod -aG systemd-journal alice 

The user must log out and back in for the group change to apply. If a colleague says "journalctl shows nothing," check the group before checking the logs.

Two maintenance commands are worth knowing. journalctl --verify checks journal files for internal consistency, and journalctl --header prints the internal header of the files being read, which helps when timestamps look out of order after a clock problem. Verification reads every file, so expect it to take time on a large journal.

A ten-minute audit

Run this as root or as a member of systemd-journal. It answers the four gate questions in one pass. It needs jq for the per-unit count (apt install jq).

#!/usr/bin/env bash set -euo pipefail echo "== journal disk usage ==" journalctl --disk-usage echo echo "== persistent storage present? ==" if [[ -d /var/log/journal ]]; then echo "yes: /var/log/journal exists" else echo "no: journal is volatile (lost on reboot)" fi echo echo "== configured limits ==" grep -RhE '^\s*(Storage|RateLimitIntervalSec|RateLimitBurst|SystemMaxUse|SystemKeepFree|SystemMaxFileSize|MaxFileSec|MaxRetentionSec|MaxLevelStore)=' \ /etc/systemd/journald.conf /etc/systemd/journald.conf.d 2>/dev/null || true echo echo "== noisiest units this boot ==" journalctl -b -o json --output-fields=_SYSTEMD_UNIT 2>/dev/null \ | jq -r '._SYSTEMD_UNIT // "kernel/other"' \ | sort | uniq -c | sort -rn | head -10 echo echo "== recent boots ==" journalctl --list-boots --no-pager | tail -5 

The noisiest-units list is the one that changes decisions. A unit producing six figures of lines per boot is either misconfigured or is your best early warning system, and either way it deserves its own rate-limit and retention policy.

What to change first

  1. Make storage explicit. Decide whether logs must survive a reboot, then set Storage= and verify /var/log/journal exists.
  2. Set a disk budget. SystemMaxUse= plus SystemKeepFree= is a policy, not a suggestion.
  3. Raise the burst for the few units that need it. Keep the global default for everything else.
  4. Do not use the local journal as an audit log. It is bounded, rate-limited, and deletable by root. If you need tamper evidence or long retention, forward records off-box and keep a separate audit trail.
  5. Query fields before text. _SYSTEMD_UNIT, PRIORITY, and --since narrow the search without parsing prose.

The next time a log line is missing, resist the urge to add more print statements. Find out which gate dropped it. The journal is usually telling the truth; you just have to ask in its language.

Sources and further reading