﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	uname	nginx_version
625	access_log directive: if= bug for buffered logs	Anton Yuzhaninov	Sergey Kandaurov	"In nginx 1.7.0 the if= parameter was added to the `access_log` directive for conditional logging. This condition fails to work for buffered logs.

Example nginx config:
{{{
#!nginx

# ?x=[01] or no x
map $arg_x $x1 {
  default 1;
  2       0;
}
# ?x=2 only
map $arg_x $x2 {
  default 0;
  2       1;
}

server {
  ...
  access_log /var/log/nginx/access_log;
  ...
  location = /a.gif {
    empty_gif;
    access_log /var/log/nginx/x1_log http_log buffer=16k if=$x1;
    access_log /var/log/nginx/x2_log http_log buffer=16k if=$x2;
  }

  location = /b.gif {
    empty_gif;
    access_log /var/log/nginx/x1_log http_log buffer=16k if=$x1;
    access_log /var/log/nginx/x2_log http_log buffer=16k if=$x2;
}
}}}

Test load can be created with some benchmark, e. g. `http_load` with url_file
{{{
http://127.0.0.1/a.gif
http://127.0.0.1/a.gif?x=0
http://127.0.0.1/a.gif?x=1
http://127.0.0.1/a.gif?x=2
http://127.0.0.1/b.gif
http://127.0.0.1/b.gif?x=0
http://127.0.0.1/b.gif?x=1
http://127.0.0.1/b.gif?x=2
}}}

After test in the x1_log file I can see requests to /b.gif?x=2 and /b.gif, /b.gif?x=0 in the x2_log. This is wrong.

After removing buffer=16k from access_log directive condition works just fine."	defect	closed	minor		nginx-core	1.7.x	fixed			FreeBSD aleph.mgmt.vega.ru 10.0-STABLE-20140715 FreeBSD 10.0-STABLE-20140715 #0 r268644M: Tue Jul 15 07:55:58 UTC 2014     root@aleph.mgmt.vega.ru:/usr/obj/usr/src/sys/MGMT  amd64	"nginx version: nginx/1.7.4
TLS SNI support enabled
configure arguments: --prefix=/usr/local/vega --with-cc-opt='-I /usr/local/include' --with-ld-opt='-L /usr/local/lib' --conf-path=/usr/local/vega/etc/service/nginx_frontend/nginx.conf --sbin-path=/usr/local/vega/sbin/nginx-frontend --pid-path=/usr/local/vega/run/nginx-frontend/nginx.pid --http-client-body-temp-path=/usr/local/vega/run/nginx-frontend/client_body_temp --http-proxy-temp-path=/usr/local/vega/run/nginx-frontend/proxy_temp --http-fastcgi-temp-path=/usr/local/vega/run/nginx-frontend/fastcgi_temp --http-log-path=/usr/local/vega/run/nginx-frontend/access_log --error-log-path=/usr/local/vega/run/nginx-frontend/error_log --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --without-select_module --without-poll_module --without-http_browser_module --without-http_limit_conn_module --user=vega.www --group=vega.www --with-debug"
