Log Rotation
Learning Focus
By the end of this lesson you will know how to configure log rotation to manage disk space effectively.
Why Log Rotation Matters
Without rotation, log files grow indefinitely and can fill the disk, causing server failures.
Built-in Rotation (WebAdmin)
- Server Configuration → Log → Rolling Size
- Set a maximum file size (e.g.,
100Mfor 100 megabytes) - When the log reaches this size, OpenLiteSpeed creates a new log file
System-Level Rotation (logrotate)
cat > /etc/logrotate.d/openlitespeed << 'EOF'
/usr/local/lsws/logs/*.log {
daily
missingok
rotate 14
compress
notifempty
postrotate
/usr/local/lsws/bin/lswsctrl restart
endscript
}
EOF
Monitoring Log Size
# Check current log sizes
du -sh /usr/local/lsws/logs/*
# Set up a simple alert
find /usr/local/lsws/logs/ -size +500M -exec echo "WARNING: Large log file: {}" \;
Key Takeaways
- Configure rotation by size to prevent disk exhaustion.
- Use either built-in rolling or system
logrotate. - Monitor log sizes, especially on busy servers.
What's Next
- Return to the Logging and Monitoring module for the complete overview.