Welcome! Log In Create A New Profile

Advanced

Re: empty variable in access log

Frank Liu
November 30, 2020 07:46PM
BTW, if I set error_log to "warn", I do see:

2020/12/01 00:32:46 [warn] 7356#7356: *1 using uninitialized "test_var"
variable while logging request, client: 127.0.0.1, server: _, request: "GET
/ HTTP/1.1", host: "localhost"

The confusion was whether those uninitialized variables should be logged as
"-", or "" (as if it is initialized with ""). I mis-read your earlier
comment "If the variable value is not found, a hyphen (“-”) will be
logged.". I took it as "if variable is uninitialized, a hyphen is logged".



On Mon, Nov 30, 2020 at 4:37 PM Frank Liu <gfrankliu@gmail.com> wrote:

> Thanks Maxim,
>
> If I understand correctly, the uninitialized custom variable is the same
> as a variable initialized as "". That's why we don't see "-", but only see
> "".
> Only internal variables will have the special "-" treatment.
>
> Frank
>
>
> On Mon, Nov 30, 2020 at 4:27 PM Maxim Dounin <mdounin@mdounin.ru> wrote:
>
>> Hello!
>>
>> On Mon, Nov 30, 2020 at 03:26:59PM -0800, Frank Liu wrote:
>>
>> > ok, for testing, I removed the variable from the map, and add one line
>> in a
>> > 2-way SSL server config, to create a fresh new variable:
>> >
>> > set $test_var "test";
>> >
>> > For a request without client cert (400), I see neither "test", nor "-"
>> in
>> > the access log for $test_var. I only see blank, as if the $test_var was
>> set
>> > to "".
>>
>> That's because variables defined due to "set" somewhere in the
>> configuration default to "" with an optional warning
>> (http://nginx.org/r/uninitialized_variable_warn). And in your
>> test the variable is uninitialized, as the set directive is not
>> executed for the request in question.
>>
>> The "-" special value can be seen for various builtin variables,
>> such as non-existing headers ($http_*, $sent_http_*,
>> $upstream_http_*), non-existing arguments ($arg_*), cookies
>> ($cookie_*), $content_length if not available, $remote_user if not
>> provided or empty, and so on.
>>
>> --
>> Maxim Dounin
>> http://mdounin.ru/
>> _______________________________________________
>> nginx mailing list
>> nginx@nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx
>>
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

empty variable in access log

Frank Liu November 29, 2020 08:36AM

Re: empty variable in access log

Maxim Dounin November 30, 2020 08:30AM

Re: empty variable in access log

Frank Liu November 30, 2020 05:06PM

Re: empty variable in access log

Maxim Dounin November 30, 2020 05:46PM

Re: empty variable in access log

Frank Liu November 30, 2020 06:28PM

Re: empty variable in access log

Maxim Dounin November 30, 2020 07:28PM

Re: empty variable in access log

Frank Liu November 30, 2020 07:38PM

Re: empty variable in access log

Frank Liu November 30, 2020 07:46PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 307
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready