Nginx log file changing automatically from *.log to *.log.1

log-filesloggingnginx

I am having issues in nginx log files.

Previously I only made logs to files,

            access_log /var/log/nginx/infotrack_access.log rsyslog;

I added the following file to my /etc/nginx/sites-available/alpha.conf file,

                access_log syslog:server=localhost:514,tag=infotrack rsyslog;

After I added this line, I am having issues that instead of the file infotrack_access.log, the logs are being made in the file infotrack_access.log.1 .

Here is the /etc/logrotate.d/nginx file,

/var/log/nginx/*.log {
    daily
    missingok
    rotate 14
    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
            invoke-rc.d nginx rotate >/dev/null 2>&1
    endscript
}

When I reload or restart nginx, then for a moment the logs are made to innfotrack_access.log, but after a moment, the logs again go to infotrack_access.log.1

Why is this happening ?
I have made no changes in /etc/nginx/nginx.conf file.

How I can solve it ?

Best Answer

Run logroate in debug and force mode. logrotate --force -d /etc/logrotate.d/nginx. This will show the error messages in detail. Also check the owners of the log folder.

It might be related to this bug: https://bugs.launchpad.net/nginx/+bug/1450770