Nginx

@nginx @server @logging

Changing the retention of nginx logs

You can configure Nginx to save and rotate logs for whatever duration and time step you want.

On server, edit /etc/logrotate.d/nginx

The example below shows a config that starts a new file every day, and keeps the last 14 logfiles

/var/log/nginx/*.log {
	daily # This tells it to start a new logfile daily
	missingok
	rotate 14  # THis tells it to keep the last 14 logfiles. 
	compress
	delaycompress
	notifempty
	create 0640 www-data adm
	sharedscripts
	prerotate
		if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
			run-parts /etc/logrotate.d/httpd-prerotate; \
		fi \
	endscript
	postrotate
		service nginx rotate >/dev/null 2>&1
	endscript
}