Configure logging

Description

In this guide, you will learn how to configure systemd-journald to limit disk usage and automatically remove old log entries.

We are using the Linux operating system Ubuntu 24.04.

What you’ll learn
  • Configure the maximum disk space used by system logs.
  • Keep a minimum amount of free disk space.
  • Limit the size of individual log files.
  • Automatically remove logs older than 7 days.
  • Configure which log levels are stored.
  • Restart systemd-journald to apply the changes.
Step by step guide
Bash
# Step 1: Open the journald configuration
nano /etc/systemd/journald.conf

# Step 2: Add or modify the following settings and save them
SystemMaxUse=200M
SystemKeepFree=100M
SystemMaxFileSize=50M
MaxRetentionSec=7day
MaxLevelStore=warning
2. Restart journald

# Step 3: Restart the service:
systemctl restart systemd-journald
Next steps