Skip to main content

Log raoted policy enforcement

Final logrotate config for access.json

Create / edit:


sudo nano /etc/logrotate.d/nginx-access-json

Paste exactly this:


/var/log/nginx/access.json { daily rotate 30 maxsize 30G missingok notifempty compress delaycompress dateext dateformat -%Y%m%d copytruncate create 0640 www-data adm }

๐Ÿ” What this guarantees

Requirement Covered
Rotate daily โœ…
Keep 30 days โœ… rotate 30
Rotate early if huge โœ… maxsize 30G
No nginx reload โœ… copytruncate
Promtail-safe โœ…
Disk protected โœ…
JSON intact โœ…

๐Ÿงช Test immediately (no waiting)


sudo logrotate -d /etc/logrotate.d/nginx-access-json
sudo logrotate -f /etc/logrotate.d/nginx-access-json