mirror of
https://github.com/nginx/nginx.git
synced 2024-12-01 03:17:17 +08:00
Core: fixed handling of "stderr" in error_log.
If "stderr" was specified in one of the "error_log" directives, stderr is not redirected to the first error_log on startup, configuration reload, and reopening log files.
This commit is contained in:
parent
9db2eddd8a
commit
26489b16e5
@ -387,7 +387,7 @@ main(int argc, char *const *argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (cycle->log->file->fd != ngx_stderr) {
|
||||
if (!cycle->log_use_stderr && cycle->log->file->fd != ngx_stderr) {
|
||||
|
||||
if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) {
|
||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
||||
|
@ -582,8 +582,9 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
|
||||
|
||||
/* commit the new cycle configuration */
|
||||
|
||||
if (!ngx_use_stderr && cycle->log->file->fd != ngx_stderr) {
|
||||
|
||||
if (!ngx_use_stderr && !cycle->log_use_stderr
|
||||
&& cycle->log->file->fd != ngx_stderr)
|
||||
{
|
||||
if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) {
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||
ngx_set_stderr_n " failed");
|
||||
@ -1228,7 +1229,7 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user)
|
||||
file[i].fd = fd;
|
||||
}
|
||||
|
||||
if (cycle->log->file->fd != ngx_stderr) {
|
||||
if (!cycle->log_use_stderr && cycle->log->file->fd != ngx_stderr) {
|
||||
|
||||
if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) {
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||
|
@ -41,6 +41,8 @@ struct ngx_cycle_s {
|
||||
ngx_log_t *log;
|
||||
ngx_log_t new_log;
|
||||
|
||||
ngx_uint_t log_use_stderr; /* unsigned log_use_stderr:1; */
|
||||
|
||||
ngx_connection_t **files;
|
||||
ngx_connection_t *free_connections;
|
||||
ngx_uint_t free_connection_n;
|
||||
|
@ -438,6 +438,7 @@ ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
|
||||
if (ngx_strcmp(value[1].data, "stderr") == 0) {
|
||||
ngx_str_null(&name);
|
||||
cf->cycle->log_use_stderr = 1;
|
||||
|
||||
} else {
|
||||
name = value[1];
|
||||
|
@ -4898,6 +4898,7 @@ ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
|
||||
if (ngx_strcmp(value[1].data, "stderr") == 0) {
|
||||
ngx_str_null(&name);
|
||||
cf->cycle->log_use_stderr = 1;
|
||||
|
||||
} else {
|
||||
name = value[1];
|
||||
|
Loading…
Reference in New Issue
Block a user