2

We're running Nginx on a couple Ubuntu servers (16.04) and all in all everything is working fine. However after some time (few days) Nginx stops logging requests to the logs (/var/log/nginx/[host].log). If I restart Nginx logging resumes/starts back up. But pretty frustrating as I don't know exactly when logging stops and all in all, don't want to not be logging the traffic.

Thoughts on what could be causing this or how to fix?

Logrotate config:

/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
}
2
  • How have you configured log rotation? – Michael Hampton Jan 11 '19 at 19:44
  • Updated the question with the logrotate config. This is the default config that was loaded when installing nginx (never looked at until now). – djneely Jan 21 '19 at 15:22
2

I ran across this question just the other day:

https://unix.stackexchange.com/questions/259091/nginx-log-rotation-doesnt-seem-to-be-working-correctly

Looking at that answer, on our servers I changed the line:

invoke-rc.d nginx rotate

to:

invoke-rc.d nginx reload

instead and now things appear to be working as expected now. Not sure why the default logrorate config for these Ubuntu and Debian boxes aren't doing that already but rotate does not seem to be working as maybe it was intended?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.