[Patch] Option to not use the default error log file during startup

Hongli Lai lists at ruby-forum.com
Sat Nov 13 17:20:10 MSK 2010


Nginx always tries to open its default log file ($prefix/log/error.log)
even if I specified a different error_log in the config file. This is
done inside ngx_log_init(). This has two implications:

1. All errors that occur before the error log - as specified in the
config file - is opened, will be printed to the default error log and to
stderr.
2. If the default error log cannot be opened, e.g. because of
permissions, Nginx will print a warning.

(1) is fine for most cases where the user did not specify a different
error log. Nginx will, in those cases, write pre-config-load errors to
the error log file that the user expects as well as to stderr. However I
have a setup in which many different users use the same Nginx
executable, but each one with a different config file and error log
file. Users do not have write permission to the default error log file,
so because of (2), Nginx always prints the warning, which can be
confusing to them.

Ideally I would like Nginx to always write to the error log file as
specified in the config, and never to the default error log file, but it
seems that the codebase does not allow this and assumes logging
facilities to be available even before the config file is loaded.

Attached to this email is a patch which modifies ngx_log_init() to
ignore the default error log file if the environment variable
NGX_EARLY_LOG_TO_STDERR is set.

Attachments:
http://www.ruby-forum.com/attachment/5362/0001-Add-an-option-to-ignore-the-default-error-log-file-d.pa


-- 
Posted via http://www.ruby-forum.com/.



More information about the nginx mailing list