changeset 1168:384bb0349a8a

Documented the "if" parameter of the "access_log" directive.
author Yaroslav Zhuravlev <yar@nginx.com>
date Thu, 24 Apr 2014 12:25:59 +0400
parents cac06b81957c
children 525190b17193
files xml/en/docs/http/ngx_http_log_module.xml
diffstat 1 files changed, 23 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/xml/en/docs/http/ngx_http_log_module.xml
+++ b/xml/en/docs/http/ngx_http_log_module.xml
@@ -10,7 +10,7 @@
 <module name="Module ngx_http_log_module"
         link="/en/docs/http/ngx_http_log_module.html"
         lang="en"
-        rev="11">
+        rev="12">
 
 <section id="summary">
 
@@ -51,16 +51,19 @@ access_log /spool/logs/nginx-access.log 
     <value>path</value>
     [<value>format</value>
     [<literal>buffer</literal>=<value>size</value>
-    [<literal>flush</literal>=<value>time</value>]]]</syntax>
+    [<literal>flush</literal>=<value>time</value>]]
+    [<literal>if</literal>=<value>condition</value>]]</syntax>
 <syntax>
     <value>path</value>
     <value>format</value>
     <literal>gzip[=<value>level</value>]</literal>
     [<literal>buffer</literal>=<value>size</value>]
-    [<literal>flush</literal>=<value>time</value>]</syntax>
+    [<literal>flush</literal>=<value>time</value>]
+    [<literal>if</literal>=<value>condition</value>]</syntax>
 <syntax>
     <literal>syslog:</literal><literal>server</literal>=<value>address</value>[,<value>parameter</value>=<value>value</value>]
-    [<value>format</value>]</syntax>
+    [<value>format</value>
+    [<literal>if</literal>=<value>condition</value>]]</syntax>
 <syntax><literal>off</literal></syntax>
 <default>logs/access.log combined</default>
 <context>http</context>
@@ -179,6 +182,22 @@ server {
 </para>
 
 <para>
+The <literal>if</literal> parameter (1.7.0) enables conditional logging.
+A request will not be logged if the <value>condition</value> evaluates to “0”
+or an empty string.
+In the following example, the requests with response codes 2xx and 3xx
+will not be logged:
+<example>
+map $status $loggable {
+    ~^[23]  0;
+    default 1;
+}
+
+access_log /path/to/access.log combined if=$loggable;
+</example>
+</para>
+
+<para>
 The following parameters configure logging to syslog:
 <list type="tag">