$time_iso8601 is not set for invalid HTTP?

igorb nginx-forum at nginx.us
Sat Nov 29 20:48:24 UTC 2014


I use the if trick to get timestamped log names:

if ($time_iso8601 ~ "^(\d{4})-(\d{2})") {
	set $year $1;
	set $month $2;
}

access_log .../access-$year-$month.log combined;

However, with nginx/1.4.6 (Ubuntu) I see that for invalid HTTP requests
$year and $month are not set. For example, with the above config after
issuing from a shell:

~> printf foo | nc host 80

I see in the error log for nginx:

2014/11/29 21:28:57 [warn] 8#0: *18 using uninitialized "year" variable
while logging request, client: 172.17.42.1, server: localhost, request:
"foo"
2014/11/29 21:28:57 [warn] 8#0: *18 using uninitialized "month" variable
while logging request, client: 172.17.42.1, server: localhost, request:
"foo"

That leads for the log file named .access--.log

Is it because $time_iso8601 is only set for valid request? If so, is this
just a bug or a feature?

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



More information about the nginx mailing list