Welcome! Log In Create A New Profile

Advanced

Re: Issue with variables in access_log and error_log

July 29, 2009 02:41PM
On Wed, Jul 29, 2009 at 07:55:09PM +0200, Dale Gallagher wrote:

> Dale Gallagher wrote:
> > access_log $webroot/$domain/log/access.log;
> > error_log $webroot/$domain/log/error.log error;
>
> I've just seen the other post about error_log not supporting
> variables, so changed the config to that below.
>
> error_log /var/www/default/log/error.log error;
>
> set $webroot /var/www;
>
> set $domain $host;
> # remove www hostname, if there
> if ($domain ~ "^(w{3}\.)?(.*)") {
> set $domain $2;
> }
>
> open_log_file_cache max=1000;
> access_log /var/www/$domain/log/access.log;

Since 0.7.44 you may use

server_name ~^(w{3}\.)?(.*)$;
set $domain $2;
open_log_file_cache max=1000;
access_log /var/www/$domain/log/access.log;

> I had to omit the use of $webroot as the first part of the access_log
> path because nginx prepended /usr and the moaned about permission
> denied (obviously). ie. it was:
>
> access_log $webroot/$domain/log/access.log
>
> ... which nginx expanded to /usr//var/ww/$domain/log/access.log
>
> so I had to hard-code the config as:
>
> access_log /var/www/$domain/log/access.log
>
> Is the above a bug perhaps, or something to do with how I built nginx?
> It seems if there isn't a '/' at the beginning of the path (before the
> variables are expanded) that /usr is prepended.

This is a bug. Currently this works as expected only for

root $var;

> Lastly, why include support for variable expansion in access_log, but
> not error_log. I'm curious.

First of all, I personally never use access_log with variables.
However, I use separate access_log's for servers. As to error_log I usually
use single log for all sites, since nginx logs enough information required
to identify server: "server: ..., host: ...". I prefer to look problems
in single place.


--
Igor Sysoev
http://sysoev.ru/en/
Subject Author Posted

Issue with variables in access_log and error_log

dale gallagher July 29, 2009 01:30PM

Re: Issue with variables in access_log and error_log

Maxim Dounin July 29, 2009 01:54PM

Re: Issue with variables in access_log and error_log

Dale Gallagher July 29, 2009 01:55PM

Re: Issue with variables in access_log and error_log

Igor Sysoev July 29, 2009 02:41PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 141
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready