Set log retention
For administrators. Apart from 404.log (30 days), security.log (90) and csp.log (30), kernel logs are rotated by size
only and have no age limit by default (Log retention).
Contents
Before you start
- The periods decided with your DPO and security officer (long enough for investigations).
- The log keys: see Setup > Log files (the key is in each log's permalink,
setup/logs/view/<key>), or./console exp:logs --archives --allow-root-user.
Steps
In
settings/override/logviewer.ini.append.php:[RotationSettings] MaxAgeDays[error]=90 MaxAgeDays[warning]=30 MaxAgeDays[notice]=30 MaxAgeDays[auth]=90 Compress[error]=enabledor one default for every log without its own entry in
settings/override/site.ini.append.php:[FileSettings] LogFileMaxAge=90.Schedule pruning: add the cronjob part
logsto the site user's crontab, for example15 3 * * * cd /path/to/exponential && php runcronjobs.php -q logs.Clear the INI cache.
Check that it worked
./console exp:logs --archives --allow-root-user # shows the limits per log
./console exp:logs --prune --dry-run --allow-root-user # what would go nowAfter the first night, the audit shows system.log.delete for pruned archives.
Related pages
- Log retention
- Log rotation and pruning
- Retention of personal data: an overview
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.