taobao/tengine — pull request #159 by cfsego (2013-01-07 06:24:42+00:00)
Title: conditional log for tengine.

example:

http {
log_env $tmd {
if ($uri != '/us');
if ($status != 200);
}

log_env $tmd1 {
if ($uri != '/usr');
sample .25;
}

log_env $tmd2 {
sample 1;
}

map $r $d {
1 0;
}

server {
listen 3130 default;

set $r 1;

log_condition {
if ($status != 200);
if ($uri != '/us');
sample 0.5;
}

location /us {
empty_gif;

access_log logs/access6.log combined env=$tmd1;
access_log logs/access7.log combined;
}

location /usr {

empty_gif;

access_log logs/aaaa;
access_log logs/access1.log combined ratio=.25;
access_log logs/access2.log combined env=$tmd;
access_log logs/access3.log combined env=$tmd1 ratio=.1;
access_log logs/access4.log combined env=$tmd2 ratio=.2;
access_log logs/access5.log combined ratio=.5 env=$tmd2;
access_log logs/access8.log combined ratio=.5 env=$r;
access_log logs/access9.log combined ratio=.5 env=$d;
#access_log logs/access9.log combined ratio=.5 env=$k; error: $k is not defined
#access_log logs/access2.log combined env=$tmd2 env=$tmd1; error: env is duplicate
}

}