Opened 8 years ago

Closed 4 years ago

#1084 closed enhancement (wontfix)

Override previous access_log settings

Reported by: cweiske Owned by:
Priority: minor Milestone:
Component: nginx-module Version: 1.10.x
Keywords: Cc:
uname -a: Linux f30fd397a44c 4.7.2-cw #1 SMP Mon Aug 29 14:23:58 CEST 2016 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.10.0 (Ubuntu)
built with OpenSSL 1.0.2g-fips 1 Mar 2016 (running with OpenSSL 1.0.2g 1 Mar 2016)
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads

Description

I would like to be able to override the access_log setting via an additional (external) config file (use case: nginx in docker container with default configuration and some small adjustments).
But that fails: Having two access_log configuration lines leads to double entries in the access log file.

So instead of overriding the previous access_log configuration setting, the log entries are doubled.

Using access_log off and followed by a access_log /path/to/file.log leads to no log output at all. So there is currently no way to change log settings later in the configuration.
This has been discovered by other people, too: http://serverfault.com/q/729128/75968


Please make it possible to override the access log settings.

Change History (1)

comment:1 by Maxim Dounin, 4 years ago

Resolution: wontfix
Status: newclosed

Directives in nginx configuration cannot be overridden. If you already have something defined on a given configuration level, trying to redefine it would result in an error. Consider:

gzip on;
gzip off;

This would trigger an error:

nginx: [emerg] "gzip" directive is duplicate in ...

This is because trying to re-define configuration directives is a common source of errors: in complex configurations it is very easy to misunderstand configuration, for example if you can see "gzip on;" in a configuration file, but don't see "gzip off;" in some included file. Moreover, it is easy to inadvertently break configuration by flipping something carefully set in a different place of configuration.

Instead, you have to comment out existing configuration directive if you want to set a different value. Alternatively, you can define a different value on different configuration level - for example, in a given server { ... } block.

The same applies to access_log directives. Already configured access logs cannot be redefined - instead, you have to comment out the existing directives or configure different logs at another configuration level.

Note: See TracTickets for help on using tickets.