Opened 2 weeks ago

Closed 2 weeks ago

#2393 closed defect (duplicate)

Error log created and opened even when overwritten in config

Reported by: jmidt@… Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.21.x
Keywords: error_log Cc:
uname -a: Linux bb2045015 5.4.0-xilinx #1 SMP PREEMPT Mon Jul 4 06:55:08 UTC 2022 armv7l GNU/Linux
nginx -V: nginx version: nginx/1.21.1
built with OpenSSL 1.1.1l 24 Aug 2021
TLS SNI support enabled
configure arguments: --crossbuild=Linux:arm --with-endian=little --with-int=4 --with-long=4 --with-long-long=8 --with-ptr-size=4 --with-sig-atomic-t=4 --with-size-t=4 --with-off-t=8 --with-time-t=4 --with-sys-nerr=132 --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/run/nginx/client_body_temp --http-proxy-temp-path=/run/nginx/proxy_temp --http-fastcgi-temp-path=/run/nginx/fastcgi_temp --http-uwsgi-temp-path=/run/nginx/uwsgi_temp --http-scgi-temp-path=/run/nginx/scgi_temp --pid-path=/run/nginx/nginx.pid --prefix=/usr --with-threads --with-http_gzip_static_module --error-log-path=/tmp/nginx-error-log --with-http_ssl_module

Description

A file at the location of the error log, as given by the configuration flags (either the default or through --error-log-path) is created and opened, even when the error_log directive is set with the following line: error_log syslog:server=unix:/dev/log,tag=nginx,nohostname,severity=error;
This occurs both when setting this directive at the top level in nginx.conf and in the http block.
Checking with fuser, nginx keeps open filehandles to the log file.

This is not the case for the access_log, which is only created in the location specified by the access_log directive (when set), rather than the --http-log-path configuration flag.

This may be a misunderstanding on my part, but when setting the error_log directive at the top level, I would not expect a file to be created and opened at the location indicated by the configuration flag.

Change History (1)

comment:1 by Maxim Dounin, 2 weeks ago

Resolution: duplicate
Status: newclosed

The compiled-in error log is used during configuration parsing (before the error_log from nginx.conf is known), so it is always created, see #147. Starting with nginx 1.19.5, you can set error log used during configuration parsing by using the -e switch, see here.

Note: See TracTickets for help on using tickets.