either error log empty or access log empty

zhnupy nginx-forum at nginx.us
Sat Mar 24 00:48:11 UTC 2012


hello, I have an nginx/1.0.14 installation with 3 virtual hosts. Each
virtual hosts features its own error_log and access_log, problem is:
eventhough I have similar log configuration on all virtual hosts either
access.log is always empty or error.log is always empty on each virtual
hosts. 

I better explain with facts, this is nginx configuration ( I'm just
copying relevant parts please disregard any syntax error I might have
introduced by doing this) :

        server {
                listen 80 default_server;
                server_name www.HOST_A.com;
                error_log  /var/log/nginx/HOST_A.error.log error;
                access_log  /var/log/nginx/HOST_A.access.log;
                root /srv/www/HOST_A.com/public_html;
        }
        server {
                listen 80;
                server_name www.HOST_B.com;
                error_log  /var/log/nginx/HOST_B.error.log error;
                access_log  /var/log/nginx/HOST_B.access.log;
                root /srv/www/HOST_B.com/public_html;
		}
        server {
                listen 80;
                server_name www.HOST_C.com;
                error_log  /var/log/nginx/HOST_C.error.log error;
                access_log  /var/log/nginx/HOST_C.access.log;
                root /srv/www/HOST_C.com/public_html;
		}


Now, I use wget to make a request for a non existent file and get a 404
response

wget http://www.HOST_A.com/nonexistentfile.php
wget http://www.HOST_B.com/nonexistentfile.php
wget http://www.HOST_C.com/nonexistentfile.php

ls command output shows that for HOST_A only error.log gets updated, and
for HOST_B and HOST_C only access.log gets updated (I've changed
directory and file owner to nginx user and relaxed permissions but it
didn't worked):

-rw-rw-rw- 1 nginx nginx    0 Mar 23 17:28 HOST_A.access.log
-rw-rw-rw- 1 nginx nginx 1240 Mar 23 17:52 HOST_A.error.log
-rw-rw-rw- 1 nginx nginx  817 Mar 23 17:52 HOST_B.access.log
-rw-rw-rw- 1 nginx nginx    0 Mar 23 17:28 HOST_B.error.log
-rw-rw-rw- 1 nginx nginx  817 Mar 23 17:48 HOST_C.access.log
-rw-rw-rw- 1 nginx nginx    0 Mar 23 17:28 HOST_C.error.log

As you can see: either  <host>.access.log is empty or <host>.error.log
is empty

This is last line from error log of HOST_A:

2012/03/23 17:29:12 [error] 3227#0: *3 open()
"/srv/www/HOST_A.com/public_html/nonexistentfile.php" failed (2: No such
file or directory), client: XXX.XXX.XXX.XXX, server: www.HOST_A.com,
request: "GET /nonexistentfile.php HTTP/1.1", host: "HOST_A.com"

and this is last line from access log of HOST_B ( HOST_C is identical):
201.141.61.209 - - [23/Mar/2012:17:52:42 -0600] "GET
/nonexistentfile.php HTTP/1.1" 404 191 "-" "Mozilla/5.0 (Windows NT 5.1;
rv:11.0) Gecko/20100101 Firefox/11.0"


In short, I don't know why only one log file per host gets updated. 
Using htop with "L" option  I can verify that the nginx process has all
log files open and yet it doesn't write to all of them. 

I tried changing file and directory ownership but that didn't worked ( I
restarted nginx after those changes). I remember this wasn't an issue
when I started using nginx 1.0.11

I'd deeply appreciate any suggestions on this issue

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,224315,224315#msg-224315



More information about the nginx mailing list