Rotate log files before they fill the disk
Updated 27 Nov 2026 logs logrotate
Configure logrotate and journal limits so logs stay a manageable size.
logrotate
Most packages ship their own rules in /etc/logrotate.d/. For your application, create /etc/logrotate.d/app:
/var/log/app/*.log {
daily
rotate 14
compress
delaycompress
missingok
notifempty
create 0640 app app
}
Test
sudo logrotate -d /etc/logrotate.d/app # dry run
sudo logrotate -f /etc/logrotate.d/app # force once
Reopening files
A program may keep writing to the old file. Signal it in a postrotate block, or use copytruncate if it cannot reopen files (a few lines can be lost).
The journal
Set SystemMaxUse=500M in /etc/systemd/journald.conf and restart systemd-journald.
Docker
{ "log-driver": "json-file", "log-opts": { "max-size": "10m", "max-file": "3" } }
Put it in /etc/docker/daemon.json, restart Docker and recreate containers.
Retention duties
If a law or contract requires you to keep logs for a period, set rotation accordingly and copy them elsewhere.