Forum: NGINX Strange log file behavior

35c5f4b67fb34acfa1fe1e7beb869b2d?d=identicon&s=25 Grant (Guest)
on 2013-07-14 13:45
(Received via mailing list)
I noticed that most of my rotated nginx log files are empty (0 bytes).

My only access_log directive is in nginx.conf:

access_log /var/log/nginx/localhost.access_log combined;

Also nginx is currently logging to
/var/log/nginx/localhost.access_log.1 instead of localhost.access_log.

Does anyone know why these things are happening?

- Grant
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2013-07-14 20:22
(Received via mailing list)
Hello!

On Sun, Jul 14, 2013 at 04:44:53AM -0700, Grant wrote:

> I noticed that most of my rotated nginx log files are empty (0 bytes).
>
> My only access_log directive is in nginx.conf:
>
> access_log /var/log/nginx/localhost.access_log combined;
>
> Also nginx is currently logging to
> /var/log/nginx/localhost.access_log.1 instead of localhost.access_log.
>
> Does anyone know why these things are happening?

This usually happens if someone don't ask nginx to reopen log
files after a rotation.  See here for details:

http://nginx.org/en/docs/control.html#logs

--
Maxim Dounin
http://nginx.org/en/donation.html
35c5f4b67fb34acfa1fe1e7beb869b2d?d=identicon&s=25 Grant (Guest)
on 2013-07-15 11:50
(Received via mailing list)
>
> This usually happens if someone don't ask nginx to reopen log
> files after a rotation.  See here for details:
>
> http://nginx.org/en/docs/control.html#logs

I use logrotate:

/var/log/nginx/*_log {
        missingok
        sharedscripts
        postrotate
                test -r /run/nginx.pid && kill -USR1 `cat
/run/nginx.pid`
        endscript
}

Does it look OK?

- Grant
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2013-07-15 12:37
(Received via mailing list)
Hello!

On Mon, Jul 15, 2013 at 02:49:47AM -0700, Grant wrote:

> >
>         postrotate
>                 test -r /run/nginx.pid && kill -USR1 `cat /run/nginx.pid`
>         endscript
> }
>
> Does it look OK?

Make sure paths used in postrotate are correct.

--
Maxim Dounin
http://nginx.org/en/donation.html
35c5f4b67fb34acfa1fe1e7beb869b2d?d=identicon&s=25 Grant (Guest)
on 2013-07-15 12:44
(Received via mailing list)
>> >
>>         postrotate
>>                 test -r /run/nginx.pid && kill -USR1 `cat /run/nginx.pid`
>>         endscript
>> }
>>
>> Does it look OK?
>
> Make sure paths used in postrotate are correct.

The paths are correct.  I made some tweaks and I'll report back
tomorrow on how it goes.  Any other ideas?

- Grant
Bb9c2912739ece4181267a3866c0ce76?d=identicon&s=25 Igor Sverkos (Guest)
on 2013-07-15 14:53
(Received via mailing list)
Hi,

> Any other ideas?

Not sure if relevant, but in Gentoo's bug tracker are some open bugs
regarding current logrotate versions:

https://bugs.gentoo.org/show_bug.cgi?id=476202
https://bugs.gentoo.org/show_bug.cgi?id=474572
https://bugs.gentoo.org/show_bug.cgi?id=476720

Seems to be upstream bugs (not Gentoo specific). So maybe you are
affected, too? Which logrotate version do you use?


--
Regards,
Igor
35c5f4b67fb34acfa1fe1e7beb869b2d?d=identicon&s=25 Grant (Guest)
on 2013-07-15 17:07
(Received via mailing list)
> affected, too? Which logrotate version do you use?
I'm on Gentoo also and I think you nailed it.  I will watch those
bugs.  Thank you!

- Grant
35c5f4b67fb34acfa1fe1e7beb869b2d?d=identicon&s=25 Grant (Guest)
on 2013-07-18 14:49
(Received via mailing list)
>
> This usually happens if someone don't ask nginx to reopen log
> files after a rotation.  See here for details:
>
> http://nginx.org/en/docs/control.html#logs

I tried issuing kill -USR1 `cat /run/nginx.pid` manually but
nginx-1.4.1 still logged to the old file.  I got the following in
error_log:

signal 10 (SIGUSR1) received, reopening logs
reopening logs

It does start logging to the new file if I restart nginx afterward.  I
also noticed this in error_log from when logrotate executes:

open() "/var/log/nginx/error_log" failed (13: Permission denied)
open() "/var/log/nginx/localhost.access_log" failed (13: Permission
denied)
open() "/var/log/nginx/localhost.error_log" failed (13: Permission
denied)

Is something happening out of order?

- Grant
Bb9c2912739ece4181267a3866c0ce76?d=identicon&s=25 Igor Sverkos (Guest)
on 2013-07-18 15:15
(Received via mailing list)
Hi,

you are right. There is a problem:

https://bugs.gentoo.org/show_bug.cgi?id=473036

Upstream (nginx) accepted the report:
http://trac.nginx.org/nginx/ticket/376


--
Regards,
Igor
35c5f4b67fb34acfa1fe1e7beb869b2d?d=identicon&s=25 Grant (Guest)
on 2013-07-18 15:55
(Received via mailing list)
> you are right. There is a problem:
>
> https://bugs.gentoo.org/show_bug.cgi?id=473036
>
> Upstream (nginx) accepted the report:
> http://trac.nginx.org/nginx/ticket/376

Many thanks Igor!  You've saved me a lot of trouble.

- Grant
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2013-07-18 17:02
(Received via mailing list)
Hello!

On Thu, Jul 18, 2013 at 03:14:10PM +0200, Igor Sverkos wrote:

> Hi,
>
> you are right. There is a problem:
>
> https://bugs.gentoo.org/show_bug.cgi?id=473036
>
> Upstream (nginx) accepted the report:
> http://trac.nginx.org/nginx/ticket/376

The "accepted" part is about future enhancement.  The Gentoo part
seems to be about wrong permissions on a log directory, which
result in non-working USR1.

--
Maxim Dounin
http://nginx.org/en/donation.html
35c5f4b67fb34acfa1fe1e7beb869b2d?d=identicon&s=25 Grant (Guest)
on 2013-07-18 17:34
(Received via mailing list)
>> you are right. There is a problem:
>>
>> https://bugs.gentoo.org/show_bug.cgi?id=473036
>>
>> Upstream (nginx) accepted the report:
>> http://trac.nginx.org/nginx/ticket/376
>
> The "accepted" part is about future enhancement.  The Gentoo part
> seems to be about wrong permissions on a log directory, which
> result in non-working USR1.

It appears you are right.  Thank you for clearing that up Maxim.

- Grant
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.