Warm tip: This article is reproduced from serverfault.com, please click

linux-Nginx不记录(需要重新启动)

(Nginx not logging (restart needed))

发布于 2021-03-19 08:23:28

我们正在几台Ubuntu服务器(16.04)上运行Nginx,所有一切都正常运行。但是,经过一段时间(几天)之后,Nginx停止将请求记录到日志中(/var/log/nginx/[host].log)。如果我重新启动Nginx,则日志记录将继续/开始备份。但是非常令人沮丧,因为我不知道确切什么时候停止日志记录,总之,我不想不记录流量。

关于什么可能导致此问题或如何解决的想法?

Logrotate配置:

/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
}
Questioner
djneely
Viewed
0
djneely 2019-01-25 01:46:41

前几天,我遇到了这个问题:

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

看着那个答案,在我们的服务器上我改变了这一行:

invoke-rc.d nginx rotate

到:

invoke-rc.d nginx reload

相反,现在一切似乎按预期运行。不确定为什么这些Ubuntu和Debian机器的默认logrorate配置尚未完成,但rotate似乎并未按预期工作吗?