4

How to configure your system to preserve system logs after a reboot

 1 year ago
source link: https://www.redhat.com/sysadmin/store-linux-system-journals
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Posted: June 2, 2022 | by Evans Amoany (Sudoer)

Image
How to create a physical volume in LVM

Log entries for the systemd-journald service, which is at the heart of the logging architecture in Red Hat Enterprise Linux (RHEL), do not persist across reboots.

This means entries are wiped after a reboot, so you won't have historical data for analysis. However, with a little configuration, you can keep log entries even after a reboot.

Keep system journals after a reboot

The process involves creating a storage location (probably in /var/log) and then editing the journald configuration to direct messages to that location.

Create a storage directory

First, create a journal directory under the /var/log directory:

[server]$ sudo mkdir /var/log/journal

Edit the journald.conf file

Edit the file /etc/systemd/journald.conf and set the Storage parameter to persistent (it is set to auto by default):

[server]$ sudo vim /etc/systemd/journald.conf
[Journal]
Storage=persistent 
[...]

[ How are your text editor skills? Read up on Vim and Nano competencies to find out. ] 

Restart systemd-journald

Next, restart the systemd-journald service:

[server]$ systemctl restart systemd-journald

Reboot the server

Finally, reboot the server to confirm the persistence of entries by listing the /var/log/journal content. You should have output that looks similar to this:

[server]$ ls /var/log/journal
75ab164a278e48be9cf80d80716a8cd9

Wrap up

The logging capabilities of systemd-journald are critical, but the default configuration does not preserve these logs. Having data to analyze is vital when troubleshooting or profiling your system. Use this simple configuration to keep your system journals for as long as you need them.

[ Free download: Advanced Linux commands cheat sheet. ]

Check out these related articles on Enable Sysadmin

Image
Laptop with code, pen, notebook
Learn how to use rsyslog and systemd-journald to get information about what's happening on your system.
Posted: May 18, 2022
Image
Woman monitoring data center systems
Keeping tabs on your infrastructure's health can be the difference between reacting to problems and preventing issues before they get out of hand.
Posted: November 18, 2021
Image
Typing on a laptop with headphones next to the computer
Once you've committed Vi's keyboard shortcuts to muscle memory, watch how fast you work.
Posted: January 25, 2022

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK