Chapter 2. Troubleshooting problems by using log files


Use log files to troubleshoot and monitor the system. Log files contain messages about the system, kernel, services, and applications, recorded efficiently using the built-in syslog protocol.

2.1. Basic troubleshooting by using log files

Investigate system problems by examining journal entries and traditional log files. Filtering logs by time, service, and priority helps you quickly narrow down the root cause.

Prerequisites

  • You are logged in to the system.

Procedure

  1. View log messages from the current boot:

    $ journalctl -b
  2. Filter log messages by a specific time range:

    $ journalctl --since "2025-07-01 08:00:00" --until "2025-07-01 12:00:00"
  3. Display only error and higher-priority messages:

    $ journalctl -p err -b
  4. Filter messages by a specific service:

    $ journalctl -u <service_name>.service -b
  5. Examine traditional log files for services that do not log through the journal:

    # cat /var/log/messages

    Some services store logs in subdirectories under /var/log/. For example, the httpd service uses /var/log/httpd/.

  6. Follow new log entries in real time to observe ongoing issues:

    $ journalctl -f

Verification

  • Verify that the log output contains entries relevant to the issue you are investigating, such as error messages, failed service starts, or unexpected reboots.

2.2. Services that handle syslog messages

The rsyslogd and journald system services handle syslog messages. These services capture, process, and store security-relevant system events.

The following services handle syslog messages:

The systemd-journald daemon

Collects messages from the following sources and forwards them to Rsyslog for further processing:

  • Kernel
  • Early stages of the boot process
  • Standard and error output of daemons as they start and run
  • Syslog
The rsyslog service
Sorts syslog messages by type and priority and writes them to the files in the /var/log directory. The /var/log directory persistently stores the log messages.

2.3. Subdirectories that store syslog messages

Locate where system logging services store recorded syslog messages. Most log files are kept in the /var/log/ directory, often organized logically into subdirectories based on the application.

The following subdirectories under the /var/log directory store syslog messages:

/var/log/messages
all syslog messages except the following
/var/log/secure
security and authentication-related messages and errors
/var/log/maillog
mail server-related messages and errors
/var/log/cron
log files related to periodically executed tasks
/var/log/boot.log
log files related to system startup

2.4. Commands for viewing logs

You can view and manage log files by using the Journal, which is a component of systemd. It addresses problems connected with traditional logging, is closely integrated with the rest of the system, and supports various logging technologies and access management for the log files.

You can use the journalctl command to view messages in the system journal, for example:

$ journalctl -b | grep kvm
May 15 11:31:41 localhost.localdomain kernel: kvm-clock: Using msrs 4b564d01 and 4b564d00
May 15 11:31:41 localhost.localdomain kernel: kvm-clock: cpu 0, msr 76401001, primary cpu clock

2.4.1. Viewing system information

journalctl
Shows all collected journal entries.
journalctl FILEPATH
Shows logs related to a specific file. For example, the journalctl /dev/sda command displays logs related to the /dev/sda file system.
journalctl -b
Shows logs for the current boot.
journalctl -k -b -1
Shows kernel logs for the current boot.

2.4.2. Viewing information about specific services

journalctl -b _SYSTEMD_UNIT=<name.service>
Filters log to show entries matching the systemd service.
journalctl -b _SYSTEMD_UNIT=<name.service> _PID=<number>
Combines matches. For example, this command shows logs for systemd-units that match <name.service> and the PID <number>.
journalctl -b _SYSTEMD_UNIT=<name.service> _PID=<number> + _SYSTEMD_UNIT=<name2.service>
The plus sign (+) separator combines two expressions in a logical OR. For example, this command shows all messages from the <name.service> service process with the PID plus all messages from the <name2.service> service (from any of its processes).
journalctl -b _SYSTEMD_UNIT=<name.service> _SYSTEMD_UNIT=<name2.service>
This command shows all entries matching either expression, referring to the same field. Here, this command shows logs matching a systemd-unit <name.service> or a systemd-unit <name2.service>.
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat Documentation

Legal Notice

Theme

© 2026 Red Hat
Back to top