How to view logs for a specific service with journalctl
Filter and display systemd journal entries for a specific service using journalctl.
How to view logs for a specific service with journalctl
Filter and display systemd journal entries for a specific service using journalctl.
Prerequisites
- A Linux system running systemd with the systemd journal enabled.
- The name of the systemd service to inspect.
Step-by-Step: View Service Logs with journalctl
Display all journal entries for a specific service using the
-uflag. journalctl filters entries by the unit name:journalctl -u nginx.serviceLimit output to a specific time range using
--sinceand--until. journalctl accepts human-readable timestamps:journalctl -u nginx.service --since "2026-03-30 08:00" --until "2026-03-30 12:00" journalctl -u nginx.service --since "1 hour ago" journalctl -u nginx.service --since todayFollow live log output in real time using the
-fflag. journalctl streams new entries as the service writes them:journalctl -u nginx.service -fShow only error-level messages using the
-p(priority) flag. journalctl supports priority levels fromemerg(0) todebug(7):journalctl -u nginx.service -p errDisplay logs from the current boot only using the
-bflag. This excludes entries from previous boot sessions:journalctl -u nginx.service -b
How to Verify the Logs Are Complete
journalctl shows the time range of available journal entries. Check the oldest entry with
--no-pager and
head:
journalctl -u nginx.service --no-pager | head -3If the journal is configured with
Storage=volatile in
/etc/systemd/journald.conf, logs do not persist across reboots. Change to
Storage=persistent and restart
systemd-journald to retain logs.
Common Issues When Viewing Logs with journalctl
journalctl may show no output for a service if the service logs to a file instead of stdout/stderr. systemd captures only stdout and stderr from the
ExecStart process. Check the application's own log configuration.
Running journalctl without sudo may hide entries from system services. Use
sudo journalctl or add the user to the
systemd-journal group.