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
1# Step 1: Open the journald configuration
2nano /etc/systemd/journald.conf
3 
4# Step 2: Add or modify the following settings and save them
5SystemMaxUse=200M
6SystemKeepFree=100M
7SystemMaxFileSize=50M
8MaxRetentionSec=7day
9MaxLevelStore=warning
102. Restart journald
11 
12# Step 3: Restart the service:
13systemctl restart systemd-journald
Next steps