How to enable persistent logging for the systemd journal?

219 篇文章 2 订阅

https://access.redhat.com/solutions/696893

 SOLUTION 已验证 - 已更新 2019年一月18日00:39 - 

English 

环境

  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 8

问题

  • The systemd journal is configured by default to store logs only in a small ring-buffer in /run/log/journal, which is not persistent
  • Journal database logs do not survive a system reboot

决议

  • Configure systemd to persistently store journal logs in /var/log/journal by running the following commands.

Raw

# mkdir -p /var/log/journal
  • You may decide if you need to keep or remove the rsyslog package installed on the system at this point, depending on your requirements
  • See man journalctl for more information on querying the journal database for specific logs

Instead of manually creating the /var/log/journal directory, one can also change the systemd-journald configuration file:

Raw

# sed -i 's/#Storage=auto/Storage=persistent/' /etc/systemd/journald.conf
# systemctl restart systemd-journald.service

With storage option "persistent", data will be stored preferably on disk, i.e. below the /var/log/journal hierarchy (which is created if needed), with a fallback to /run/log/journal (which is created if needed), during early boot and if the disk is not writable.

根源

  • By default in Red Hat Enterprise Linux 7 and 8, systemd is not configured to maintain logs persistently
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值