Skip to content
conditional accesslog for nginx
Branch: master
Clone or download
Latest commit 3a78876 Jul 26, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
Licence Create Licence Jun 1, 2016 Update Jul 26, 2018
config initial version Sep 18, 2012
ngx_http_aclog_bypass_module.c be compatible with tengine 2.2.0+ Jul 26, 2018


ngx_log_if_module is an independent module which allows you to control when not to write down access log, similar to the "CustomLog [env=XXX]" directive in Apache.


Syntax:  access_log_bypass_if (condition) [and]
Default: -
Scope:   main/srv/loc

"access_log_bypass_if" defines the condition that nginx will not write down access log in case it is true. The condition is enclosed by brackets... In brief, the syntax of condition in "access_log_bypass_if" is the same as it in the "if" directive. If flag "and" is added, this line will work together will the next line.


This directive allows you to define multiple conditions in the form of using the directive in multiple times in the same block. For example:

server {
    access_log_bypass_if ($status = 400);
    access_log_bypass_if ($host ~* '');
    access_log_bypass_if ($uri = 'status.nginx') and;
    access_log_bypass_if ($status = 200);

In the case, nginx will not write access log when the status code is 400, or when the host is '', or when the uri is 'status.nginx' and the status code is 200.

However, if you define them both in the blocks in the father child relationship, the child block will not inherit and merge the configuration in parent block, of course. FOr example:

server {
    access_log_bypass_if ($status = 400);

    location / {
        access_log_bypass_if ($host ~* '');

In this case above, in location "/", only "($host ~* '')" is available, but "($status = 400)" is ignored and makes no difference.


1.0.4 2018-07-26 bugfixed:

1.0.3 2013-04-23 bugfixed:, thanks to yixing

1.0.2 2012-10-17 feature: flag "and" added

1.0.1 2012-10-10 bugfixed: uninitialized value is used

1.0.0 2012-09-18 initial version

You can’t perform that action at this time.