using uninitialized "pat" variable while logging request

Toni Mueller support-nginx at oeko.net
Fri Nov 15 22:24:43 UTC 2013


Hi,

to debug my locations, I have a variable in my configuration that I
reference during logging. The log format, included from nginx.conf:

 log_format mylogformat '$remote_addr - $remote_user [$time_local] $request '
                        '"$status" $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" domain: $host branch: $pat';


Unfortunately, I cannot set the variable $pat already in nginx.conf,
but in my virtual server configuration, I set it like this:

    server {
        listen          1.2.3.4:80 default_server;
        server_name     www.example.com;

	charset         utf-8;
        set             $pat "-";

        # rest of configuration here, eg.:

	location = / {
            set                 $pat "homepage";
	    # do something special
        }

        # more stuff...
    }


So far, my understanding is that the variable $pat should be _always_
defined, right? Well... I find this in the error log:

[warn] 11092#0: *15719589 using uninitialized "pat" variable while logging request, client: 4.3.2.1, server: www.example.com


For a lot of requests, the value of the variable does appear in the log
file, but for a good proportion, it doesn't. I would like to have this
variable always set properly. Can it be a timing question? I get
between ~5 and below 100 requests per second. The machine doesn't look
anywhere near loaded, though (CPU utulization is under 5%).

My software is nginx-full 1.2.1-2.2+wheezy1, on an amd64 VM.


TIA!


Kind regards,
--Toni++



More information about the nginx mailing list