Forum: NGINX BUG report: error log separation per virtual host does not work

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Dan Dascalescu (Guest)
on 2009-01-08 07:20
(Received via mailing list)
I reported this bug already at
http://thread.gmane.org/gmane.comp.web.nginx.engli...
but was using the stable version of nginx. I just upgraded to the
latest development version, 0.7.30, and the bug is still there:

I want to have separate error logs for each virtual host. Here is my
config file, with only one host so far:

error_log  logs/main_error.log;

events {
   worker_connections  1024;
}

http {
   error_log logs/http_error.log;
   server {
       server_name myname.org;
       access_log logs/the_org.access;
       error_log logs/the_org.error;
   }
}

Here is the problem: when the server receives a request for
http://myname.org/nonexistent.file, the request shows up in the access
log (the_org.access), but all 3 error logs remain blank. The error
only shows up in the main_error.log if I comment the
"error_log logs/http_error.log;"
and
"error_log logs/the_org.error;"
lines.

Can this bug please be fixed? Lighttpd's author refused to implement
error log separation (see
http://www.wikivs.com/wiki/Lighttpd_vs_nginx#Separ...)
and I really hoped that nginx could do better...

Best regards,
Dan Dascalescu
mike (Guest)
on 2009-01-08 08:08
(Received via mailing list)
Conditional error logging is one thing I'd like to see, I've asked in
the past.

For things like

if ($remote_addr ~ 10.22.33.44) {
 error_log off;
}

or location / server block based, etc?

On Wed, Jan 7, 2009 at 9:09 PM, Dan Dascalescu
Maxim D. (Guest)
on 2009-01-08 12:47
(Received via mailing list)
Hello!

On Wed, Jan 07, 2009 at 09:09:02PM -0800, Dan Dascalescu wrote:

> events {
> }
>
> Here is the problem: when the server receives a request for
> http://myname.org/nonexistent.file, the request shows up in the access
> log (the_org.access), but all 3 error logs remain blank. The error
> only shows up in the main_error.log if I comment the
> "error_log logs/http_error.log;"
> and
> "error_log logs/the_org.error;"
> lines.

The problem is that nginx sets reasonable logging level
automatically only for global error_log (it's defaults to error if
not defined).  For others it's defaults to stderr, i.e. nothing is
logged.  Solution is simple - explicitly specify logging level:

error_log logs/main_error.log error;

events {
    worker_connections  1024;
}

http {
    error_log logs/http_error.log error;
    server {
        server_name myname.org;
        access_log logs/the_org.access;
        error_log logs/the_org.error error;
    }
}

Since there is no official documentation for error_log directive
at all - this probably can't be considered as a bug.  It's up to
Igor either fix it or document as is.

Maxim D.
Dan Dascalescu (Guest)
on 2009-01-08 23:19
(Received via mailing list)
Maxim D. <mdounin@...> writes:

> The problem is that nginx sets reasonable logging level
> automatically only for global error_log (it's defaults to error if
> not defined).  For others it's defaults to stderr, i.e. nothing is
> logged.  Solution is simple - explicitly specify logging level:
>
> [...]
>
> Since there is no official documentation for error_log directive
> at all - this probably can't be considered as a bug.  It's up to
> Igor either fix it or document as is.

Thanks for the help. I documented this on the wiki at
http://wiki.codemongers.com/NginxHttpMainModule#error_log. Feel free to
correct
as necessary (in particular, I'm not sure about the default error log
levels).

Dan
Igor S. (Guest)
on 2009-01-13 15:50
(Received via mailing list)
Attachment: patch.error_log (0 Bytes)
On Thu, Jan 08, 2009 at 01:36:31PM +0300, Maxim D. wrote:

> > error_log  logs/main_error.log;
> >        error_log logs/the_org.error;
> > lines.
> }
> Since there is no official documentation for error_log directive
> at all - this probably can't be considered as a bug.  It's up to
> Igor either fix it or document as is.

The attached patch should fix the bug.
This topic is locked and can not be replied to.