How do I check for and manage system logs in Manjaro?

System logs play a crucial role in monitoring the health and performance of a Linux system, providing valuable information about events, errors, and activities. Manjaro, being a user-friendly Arch Linux derivative, makes it relatively straightforward to access and manage system logs. In this comprehensive guide, we’ll explore the various tools and techniques for checking and manageing system logs in Manjaro.

Understanding System Logs in Manjaro

1. Systemd Journal:

  • Manjaro, like many modern Linux distributions, utilises the systemd journal for centralised log management. The systemd journal collects and stores log data in binary format, making it efficient for searching and retrieving information.

2. Log Locations:

  • System logs in Manjaro are typically stored in the /var/log directory. Key log files include /var/log/journal for systemd journal files and various log files for specific services or applications.

3. Journalctl Command:

  • The journalctl command is the primary tool for querying and displaying logs from the systemd journal. It provides a wealth of options for filtering and formating log entries.

Checking System Logs with Journalctl

1. Viewing Recent Logs:

  • To view recent log entries, use the following command:
journalctl

2. Filtering by Unit (Service):

  • Filter logs for a specific service or unit:
journalctl -u [unit_name]

3. Time-based Filtering:

  • Display logs within a specific time range:
journalctl --since "yyyy-mm-dd HH:MM:SS" --until "yyyy-mm-dd HH:MM:SS"

4. Viewing Kernel Messages:

  • Display kernel messages:
journalctl -k

5. Output Formating:

  • Customise output format using options like --output, e.g.:
journalctl --output json

6. Follow Real-time Logs:

  • Monitor logs in real-time with the -f option:
journalctl -f

7. Exporting Logs to a File:

  • Save logs to a file for offline analysis:
journalctl > logs.txt

Managing System Logs

1. Clearing Old Logs:

  • To clear old journal entries and reduce disk space usage, use:
sudo journalctl --vacuum-size=50M
  • Adjust the size parameter based on your preferences.

2. Rotate and Compress Logs:

  • Manually rotate and compress logs for a specific unit:
sudo journalctl --rotate
sudo journalctl --vacuum-time=3d

3. Checking Disk Usage:

  • Assess disk space usage by the journal:
journalctl --disk-usage

4. Listing Available Units:

  • View available units (services) with logs:
journalctl --list-boots

5. Custom Log Storage Paths:

  • Configure custom paths for storing log files by editing /etc/systemd/journald.conf:
SystemMaxUse=50M

6. Forwarding Logs to Syslog:

  • Forward systemd journal logs to syslog:
ForwardToSyslog=yes

Using Graphical Log Managers

1. GNOME Logs:

  • If using the GNOME desktop environment, the GNOME Logs application provides a graphical interface for browsing system logs.

2. KDE System Monitor:

  • On KDE Plasma, the System Monitor application offers a “Journal” section for viewing logs.

3. Third-party Log Managers:

  • Explore third-party log management tools available in the Manjaro repositories or AUR (Arch User Repository) for additional functionality and convenience.

Conclusion

Effectively manageing system logs is essential for maintaining the stability and performance of your Manjaro Linux system. The systemd journal, coupled with the powerful journalctl command, provides users with a flexible and efficient way to access and analyse logs. Whether you prefer command-line tools or graphical interfaces, Manjaro offers a range of options to suit different user preferences. Regularly checking and manageing system logs empowers users to troubleshoot issues, monitor system health, and ensure a smooth and reliable computing experience on their Manjaro Linux system.

Scroll to Top