Skip to content
Browse files

first commit

  • Loading branch information...
0 parents commit 9f12aeaad8bc83736668f3821b2c7af3e0f15259 @yaoweibin committed Sep 6, 2010
Showing with 701 additions and 0 deletions.
  1. +88 −0 README
  2. +613 −0 syslog_0.7.67.patch
88 README
@@ -0,0 +1,88 @@
+==INSTALLATION==
+
+cd nginx-0.7.67
+patch -p1 < /path/to/this/directory/syslog_0.7.67.patch
+
+OR
+
+cd nginx-0.8.50
+patch -p1 < /path/to/this/directory/syslog_0.8.50.patch
+
+
+==EXAMPLE==
+
+worker_processes 1;
+
+syslog local6;
+
+events {
+ worker_connections 1024;
+}
+
+http {
+ include mime.types;
+ default_type application/octet-stream;
+
+ log_format main '$remote_addr - $remote_user [$time_local] $request '
+ '"$status" $body_bytes_sent "$http_referer" '
+ '"$http_user_agent" "$http_x_forwarded_for"';
+
+ sendfile on;
+ keepalive_timeout 65;
+
+ server {
+ listen 80;
+ server_name localhost;
+
+ access_log syslog:notice|logs/host1.access.log main;
+ error_log syslog:notice|logs/host1.error.log;
+
+ location / {
+ root html;
+ index index.html index.htm;
+ }
+ }
+
+ server {
+ listen 80;
+ server_name www.example.com;
+
+ access_log syslog:warn|logs/host2.access.log main;
+ error_log syslog:warn|logs/host2.error.log;
+
+ location / {
+ root html;
+ index index.html index.htm;
+ }
+ }
+}
+
+
+==DIRECTIVES==
+
+===SYSLOG===
+Sytax: syslog auth|authpriv|cron|daemon|ftp|kern|local0-7|lpr|mail|news|syslog|user|uucp [program_name]
+Default: none
+Context: main
+
+Enable the syslog and set its facility. The default program name is nginx.
+
+===ERROR_LOG===
+Syntax: error_log [syslog[:emerg|alert|crit|error|warn|notice|info|debug]]['|'file] [ debug | info | notice | warn | error | crit ]
+Default: ${prefix}/logs/error.log
+Context: main, http, server, location
+
+Enable the error_log with the syslog and set its priority. The default priority is error.
+
+===ACCESS_LOG===
+Syntax: access_log off|[syslog[:emerg|alert|crit|error|warn|notice|info|debug]]['|'path] [format [buffer=size]]]
+Default: access_log logs/access.log combined
+Context: http, server, location
+
+Enable the access_log with the syslog and set its priority. The default priority is notice.
+
+
+==CONTACT==
+Reporting a bug
+Questions/patches may be directed to Weibin Yao, yaoweibin@gmail.com.
+
613 syslog_0.7.67.patch
@@ -0,0 +1,613 @@
+diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
+index 770a590..b241ac8 100644
+--- a/src/core/ngx_log.c
++++ b/src/core/ngx_log.c
+@@ -6,9 +6,22 @@
+
+ #include <ngx_config.h>
+ #include <ngx_core.h>
++#include <syslog.h>
+
+
++#define SYSLOG_FACILITY LOG_LOCAL5
++#define ERR_SYSLOG_PRIORITY LOG_ERR
++
++
+ static char *ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
++static char *ngx_set_syslog(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
++void log_exit(ngx_cycle_t *cycle);
++
++
++typedef struct{
++ ngx_str_t name;
++ ngx_int_t macro;
++} ngx_string_to_macro_t;
+
+
+ static ngx_command_t ngx_errlog_commands[] = {
+@@ -20,6 +33,13 @@ static ngx_command_t ngx_errlog_commands[] = {
+ 0,
+ NULL},
+
++ {ngx_string("syslog"),
++ NGX_MAIN_CONF|NGX_CONF_TAKE12,
++ ngx_set_syslog,
++ 0,
++ 0,
++ NULL},
++
+ ngx_null_command
+ };
+
+@@ -42,7 +62,7 @@ ngx_module_t ngx_errlog_module = {
+ NULL, /* init thread */
+ NULL, /* exit thread */
+ NULL, /* exit process */
+- NULL, /* exit master */
++ log_exit, /* exit master */
+ NGX_MODULE_V1_PADDING
+ };
+
+@@ -51,6 +71,42 @@ static ngx_log_t ngx_log;
+ static ngx_open_file_t ngx_log_file;
+ ngx_uint_t ngx_use_stderr = 1;
+
++static ngx_string_to_macro_t ngx_syslog_facilities[] = {
++ {ngx_string("auth"), LOG_AUTH},
++ {ngx_string("authpriv"), LOG_AUTHPRIV},
++ {ngx_string("cron"), LOG_CRON},
++ {ngx_string("daemon"), LOG_DAEMON},
++ {ngx_string("ftp"), LOG_FTP},
++ {ngx_string("kern"), LOG_KERN},
++ {ngx_string("local0"), LOG_LOCAL0},
++ {ngx_string("local1"), LOG_LOCAL1},
++ {ngx_string("local2"), LOG_LOCAL2},
++ {ngx_string("local3"), LOG_LOCAL3},
++ {ngx_string("local4"), LOG_LOCAL4},
++ {ngx_string("local5"), LOG_LOCAL5},
++ {ngx_string("local6"), LOG_LOCAL6},
++ {ngx_string("local7"), LOG_LOCAL7},
++ {ngx_string("lpr"), LOG_LPR},
++ {ngx_string("mail"), LOG_MAIL},
++ {ngx_string("news"), LOG_NEWS},
++ {ngx_string("syslog"), LOG_SYSLOG},
++ {ngx_string("user"), LOG_USER},
++ {ngx_string("uucp"), LOG_UUCP},
++ { ngx_null_string, 0}
++};
++
++static ngx_string_to_macro_t ngx_syslog_priorities[] = {
++ {ngx_string("emerg"), LOG_EMERG},
++ {ngx_string("alert"), LOG_ALERT},
++ {ngx_string("crit"), LOG_CRIT},
++ {ngx_string("error"), LOG_ERR},
++ {ngx_string("err"), LOG_ERR},
++ {ngx_string("warn"), LOG_WARNING},
++ {ngx_string("notice"),LOG_NOTICE},
++ {ngx_string("info"), LOG_INFO},
++ {ngx_string("debug"), LOG_DEBUG},
++ { ngx_null_string, 0}
++};
+
+ static ngx_str_t err_levels[] = {
+ ngx_null_string,
+@@ -87,12 +143,9 @@ ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
+ #if (NGX_HAVE_VARIADIC_MACROS)
+ va_list args;
+ #endif
+- u_char *p, *last, *msg;
++ u_char *p, *last, *msg, *errstr_syslog;
+ u_char errstr[NGX_MAX_ERROR_STR];
+
+- if (log->file->fd == NGX_INVALID_FILE) {
+- return;
+- }
+
+ last = errstr + NGX_MAX_ERROR_STR;
+
+@@ -101,6 +154,8 @@ ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
+
+ p = errstr + ngx_cached_err_log_time.len;
+
++ errstr_syslog = p;
++
+ p = ngx_slprintf(p, last, " [%V] ", &err_levels[level]);
+
+ /* pid#tid */
+@@ -139,11 +194,21 @@ ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
+
+ ngx_linefeed(p);
+
+- (void) ngx_write_fd(log->file->fd, errstr, p - errstr);
++ if (log->file != NULL && log->file->name.len != 0) {
++ (void) ngx_write_fd(log->file->fd, errstr, p - errstr);
++ }
++
++ errstr[p - errstr] = '\0';
++
++ /* Don't send the debug info to syslog */
++ if (log->syslog_on && level < NGX_LOG_DEBUG) {
++ /* write to syslog */
++ syslog(log->priority, "%s", errstr_syslog);
++ }
+
+ if (!ngx_use_stderr
+ || level > NGX_LOG_WARN
+- || log->file->fd == ngx_stderr)
++ || (log->file != NULL && log->file->fd == ngx_stderr))
+ {
+ return;
+ }
+@@ -363,6 +428,48 @@ ngx_log_create(ngx_cycle_t *cycle, ngx_str_t *name)
+ }
+
+
++ngx_int_t
++ngx_log_get_priority(ngx_conf_t *cf, ngx_str_t *priority)
++{
++ ngx_int_t p = 0;
++ ngx_uint_t n, match = 0;
++
++ for (n = 0; ngx_syslog_priorities[n].name.len != 0; n++) {
++ if (ngx_strncmp(priority->data, ngx_syslog_priorities[n].name.data,
++ ngx_syslog_priorities[n].name.len) == 0) {
++ p = ngx_syslog_priorities[n].macro;
++ match = 1;
++ }
++ }
++
++ if (!match) {
++ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
++ "invalid syslog priority \"%V\"", priority);
++ return -1;
++ }
++
++ return p;
++}
++
++
++char *
++ngx_log_set_priority(ngx_conf_t *cf, ngx_str_t *priority, ngx_log_t *log)
++{
++ log->priority = ERR_SYSLOG_PRIORITY;
++
++ if (priority->len == 0) {
++ return NGX_CONF_OK;
++ }
++
++ log->priority = ngx_log_get_priority(cf, priority);
++ if (log->priority == (-1)) {
++ return NGX_CONF_ERROR;
++ }
++
++ return NGX_CONF_OK;
++}
++
++
+ char *
+ ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log)
+ {
+@@ -420,7 +527,8 @@ ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log)
+ static char *
+ ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+ {
+- ngx_str_t *value, name;
++ u_char *off = NULL;
++ ngx_str_t *value, name = ngx_null_string, priority = ngx_null_string;
+
+ if (cf->cycle->new_log.file) {
+ return "is duplicate";
+@@ -428,7 +536,38 @@ ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+
+ value = cf->args->elts;
+
+- if (ngx_strcmp(value[1].data, "stderr") == 0) {
++ if (ngx_strncmp(value[1].data, "syslog", sizeof("syslog") - 1) == 0) {
++ if (!cf->cycle->new_log.syslog_on) {
++ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
++ "You must set the syslog directive and enable it first.");
++ return NGX_CONF_ERROR;
++ }
++
++ if (value[1].data[sizeof("syslog") - 1] == ':') {
++ priority.len = value[1].len - sizeof("syslog");
++ priority.data = value[1].data + sizeof("syslog");
++
++ off = (u_char *)ngx_strchr(priority.data, (int) '|');
++ if (off != NULL) {
++ priority.len = off - priority.data;
++
++ off++;
++ name.len = value[1].data + value[1].len - off;
++ name.data = off;
++ }
++ }
++ else {
++ if (value[1].len > sizeof("syslog")) {
++ name.len = value[1].len - sizeof("syslog");
++ name.data = value[1].data + sizeof("syslog");
++ }
++ }
++
++ if (ngx_log_set_priority(cf, &priority, &cf->cycle->new_log) == NGX_CONF_ERROR) {
++ return NGX_CONF_ERROR;
++ }
++ }
++ else if (ngx_strcmp(value[1].data, "stderr") == 0) {
+ name.len = 0;
+ name.data = NULL;
+
+@@ -450,3 +589,60 @@ ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+
+ return ngx_log_set_levels(cf, &cf->cycle->new_log);
+ }
++
++
++#define SYSLOG_IDENT_NAME "nginx"
++
++static char *
++ngx_set_syslog(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
++{
++ char *program;
++ ngx_str_t *value;
++ ngx_int_t facility, match = 0;
++ ngx_uint_t n;
++
++ value = cf->args->elts;
++
++ if (cf->cycle->new_log.syslog_on) {
++ return "is duplicate";
++ }
++
++ cf->cycle->new_log.syslog_on = 1;
++
++ for (n = 0; ngx_syslog_facilities[n].name.len != 0; n++) {
++ if (ngx_strncmp(value[1].data, ngx_syslog_facilities[n].name.data,
++ ngx_syslog_facilities[n].name.len) == 0) {
++ facility = ngx_syslog_facilities[n].macro;
++ match = 1;
++ break;
++ }
++ }
++
++ if (match) {
++ cf->cycle->new_log.facility = facility;
++ cf->cycle->new_log.priority = ERR_SYSLOG_PRIORITY;
++ }
++ else {
++ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
++ "invalid syslog facility \"%V\"", &value[1]);
++ return NGX_CONF_ERROR;
++ }
++
++ program = SYSLOG_IDENT_NAME;
++ if (cf->args->nelts > 2) {
++ program = (char *) value[2].data;
++ }
++
++ openlog(program, LOG_ODELAY, facility);
++
++ return NGX_CONF_OK;
++}
++
++
++void log_exit(ngx_cycle_t *cycle)
++{
++ if (cycle->new_log.syslog_on) {
++ closelog();
++ }
++}
++
+diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h
+index b736aa2..b13f88c 100644
+--- a/src/core/ngx_log.h
++++ b/src/core/ngx_log.h
+@@ -60,6 +60,10 @@ struct ngx_log_s {
+ */
+
+ char *action;
++
++ ngx_int_t priority;
++ ngx_int_t facility;
++ unsigned syslog_on:1; /* unsigned :1 syslog_on */
+ };
+
+
+@@ -197,6 +201,8 @@ void ngx_cdecl ngx_log_debug_core(ngx_log_t *log, ngx_err_t err,
+
+ ngx_log_t *ngx_log_init(u_char *prefix);
+ ngx_log_t *ngx_log_create(ngx_cycle_t *cycle, ngx_str_t *name);
++ngx_int_t ngx_log_get_priority(ngx_conf_t *cf, ngx_str_t *priority);
++char * ngx_log_set_priority(ngx_conf_t *cf, ngx_str_t *priority, ngx_log_t *log);
+ char *ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log);
+ void ngx_cdecl ngx_log_abort(ngx_err_t err, const char *fmt, ...);
+ void ngx_cdecl ngx_log_stderr(ngx_err_t err, const char *fmt, ...);
+diff --git a/src/http/modules/ngx_http_log_module.c b/src/http/modules/ngx_http_log_module.c
+index 5152038..8bc586b 100644
+--- a/src/http/modules/ngx_http_log_module.c
++++ b/src/http/modules/ngx_http_log_module.c
+@@ -8,6 +8,9 @@
+ #include <ngx_core.h>
+ #include <ngx_http.h>
+
++#include <syslog.h>
++
++#define HTTP_SYSLOG_PRIORITY LOG_NOTICE
+
+ typedef struct ngx_http_log_op_s ngx_http_log_op_t;
+
+@@ -51,6 +54,9 @@ typedef struct {
+ time_t disk_full_time;
+ time_t error_log_time;
+ ngx_http_log_fmt_t *format;
++
++ ngx_int_t priority;
++ unsigned syslog_on:1; /* unsigned :1 syslog_on */
+ } ngx_http_log_t;
+
+
+@@ -312,13 +318,27 @@ ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log, u_char *buf,
+ {
+ u_char *name;
+ time_t now;
+- ssize_t n;
++ ssize_t n = 0;
+ ngx_err_t err;
++ u_char temp;
++ ngx_http_log_loc_conf_t *lcf;
+
++ lcf = ngx_http_get_module_loc_conf(r, ngx_http_log_module);
++
++ if (log->syslog_on) {
++ temp = buf[len];
++ buf[len] = '\0';
++ syslog(log->priority, "%s", buf);
++ buf[len] = temp;
++ n = len;
++ }
++
+ if (log->script == NULL) {
+- name = log->file->name.data;
+- n = ngx_write_fd(log->file->fd, buf, len);
+
++ name = log->file->name.data;
++ if (name != NULL) {
++ n = ngx_write_fd(log->file->fd, buf, len);
++ }
+ } else {
+ name = NULL;
+ n = ngx_http_log_script_write(r, log->script, &name, buf, len);
+@@ -842,14 +862,16 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+ {
+ ngx_http_log_loc_conf_t *llcf = conf;
+
++ u_char *off;
+ ssize_t buf;
+- ngx_uint_t i, n;
+- ngx_str_t *value, name;
++ ngx_uint_t i, n, syslog_on = 0;
++ ngx_str_t *value, name, priority;
+ ngx_http_log_t *log;
+ ngx_http_log_fmt_t *fmt;
+ ngx_http_log_main_conf_t *lmcf;
+ ngx_http_script_compile_t sc;
+
++ name = priority = (ngx_str_t)ngx_null_string;
+ value = cf->args->elts;
+
+ if (ngx_strcmp(value[1].data, "off") == 0) {
+@@ -862,6 +884,36 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+ "invalid parameter \"%V\"", &value[2]);
+ return NGX_CONF_ERROR;
+ }
++ else if (ngx_strncmp(value[1].data, "syslog", sizeof("syslog") - 1) == 0) {
++ if (!cf->cycle->new_log.syslog_on) {
++ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
++ "You must set the syslog directive and enable it first.");
++ return NGX_CONF_ERROR;
++ }
++
++ syslog_on = 1;
++ if (value[1].data[sizeof("syslog") - 1] == ':') {
++ priority.len = value[1].len - sizeof("syslog");
++ priority.data = value[1].data + sizeof("syslog");
++
++ off = (u_char*) ngx_strchr(priority.data, '|');
++ if (off != NULL) {
++ priority.len = off - priority.data;
++
++ off++;
++ name.len = value[1].data + value[1].len - off;
++ name.data = off;
++ }
++ }
++ else {
++ if (value[1].len > sizeof("syslog")) {
++ name.len = value[1].len - sizeof("syslog");
++ name.data = value[1].data + sizeof("syslog");
++ }
++ }
++ } else {
++ name = value[1];
++ }
+
+ if (llcf->logs == NULL) {
+ llcf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t));
+@@ -879,35 +931,48 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+
+ ngx_memzero(log, sizeof(ngx_http_log_t));
+
+- n = ngx_http_script_variables_count(&value[1]);
+
+- if (n == 0) {
+- log->file = ngx_conf_open_file(cf->cycle, &value[1]);
+- if (log->file == NULL) {
+- return NGX_CONF_ERROR;
+- }
++ log->syslog_on = syslog_on;
+
+- } else {
+- if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) {
+- return NGX_CONF_ERROR;
+- }
+-
+- log->script = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_script_t));
+- if (log->script == NULL) {
+- return NGX_CONF_ERROR;
+- }
+-
+- ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
++ if (priority.len == 0) {
++ log->priority = HTTP_SYSLOG_PRIORITY;
++ }
++ else {
++ log->priority = ngx_log_get_priority(cf, &priority);
++ }
+
+- sc.cf = cf;
+- sc.source = &value[1];
+- sc.lengths = &log->script->lengths;
+- sc.values = &log->script->values;
+- sc.variables = n;
+- sc.complete_lengths = 1;
+- sc.complete_values = 1;
++ if (name.len != 0) {
++ n = ngx_http_script_variables_count(&name);
+
+- if (ngx_http_script_compile(&sc) != NGX_OK) {
++ if (n == 0) {
++ log->file = ngx_conf_open_file(cf->cycle, &name);
++ if (log->file == NULL) {
++ return NGX_CONF_ERROR;
++ }
++ } else {
++ if (ngx_conf_full_name(cf->cycle, &name, 0) == NGX_ERROR) {
++ return NGX_CONF_ERROR;
++ }
++ log->script = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_script_t));
++ if (log->script == NULL) {
++ return NGX_CONF_ERROR;
++ }
++ ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
++ sc.cf = cf;
++ sc.source = &name;
++ sc.lengths = &log->script->lengths;
++ sc.values = &log->script->values;
++ sc.variables = n;
++ sc.complete_lengths = 1;
++ sc.complete_values = 1;
++ if (ngx_http_script_compile(&sc) != NGX_OK) {
++ return NGX_CONF_ERROR;
++ }
++ }
++ }
++ else {
++ log->file = ngx_conf_open_file(cf->cycle, &name);
++ if (log->file == NULL) {
+ return NGX_CONF_ERROR;
+ }
+ }
+diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
+index 479592a..8a0f8ef 100644
+--- a/src/http/ngx_http_core_module.c
++++ b/src/http/ngx_http_core_module.c
+@@ -1337,6 +1337,7 @@ ngx_http_update_location_config(ngx_http_request_t *r)
+
+ if (r == r->main) {
+ r->connection->log->file = clcf->error_log->file;
++ r->connection->log->priority = clcf->error_log->priority;
+
+ if (!(r->connection->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
+ r->connection->log->log_level = clcf->error_log->log_level;
+@@ -4105,6 +4106,9 @@ ngx_http_core_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+ static char *
+ ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+ {
++ u_char *off = NULL;
++ ngx_int_t syslog_on = 0;
++ ngx_str_t name, priority;
+ ngx_http_core_loc_conf_t *lcf = conf;
+
+ ngx_str_t *value;
+@@ -4113,18 +4117,60 @@ ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+ return "is duplicate";
+ }
+
++ name = priority = (ngx_str_t) ngx_null_string;
+ value = cf->args->elts;
+
+- lcf->error_log = ngx_log_create(cf->cycle, &value[1]);
++ if (ngx_strncmp(value[1].data, "syslog", sizeof("syslog") - 1) == 0) {
++ if (!cf->cycle->new_log.syslog_on) {
++ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
++ "You must set the syslog directive and enable it first.");
++ return NGX_CONF_ERROR;
++ }
++
++ syslog_on = 1;
++
++ if (value[1].data[sizeof("syslog") - 1] == ':') {
++ priority.len = value[1].len - sizeof("syslog");
++ priority.data = value[1].data + sizeof("syslog");
++
++ off = (u_char*) ngx_strchr(priority.data, '|');
++ if (off != NULL) {
++ priority.len = off - priority.data;
++
++ off++;
++ name.len = value[1].data + value[1].len - off;
++ name.data = off;
++ }
++ }
++ else {
++ if (value[1].len > sizeof("syslog")) {
++ name.len = value[1].len - sizeof("syslog");
++ name.data = value[1].data + sizeof("syslog");
++ }
++ }
++ } else {
++ name = value[1];
++ }
++
++ lcf->error_log = ngx_log_create(cf->cycle, &name);
+ if (lcf->error_log == NULL) {
+ return NGX_CONF_ERROR;
+ }
+
++ if (syslog_on) {
++ lcf->error_log->syslog_on = 1;
++ if (ngx_log_set_priority(cf, &priority, lcf->error_log) == NGX_CONF_ERROR) {
++ return NGX_CONF_ERROR;
++ }
++ }
++
+ if (cf->args->nelts == 2) {
+ lcf->error_log->log_level = NGX_LOG_ERR;
+ return NGX_CONF_OK;
+ }
+
++ lcf->error_log->log_level = 0;
++
+ return ngx_log_set_levels(cf, lcf->error_log);
+ }
+
+diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
+index 5710c69..f2fd3c7 100644
+--- a/src/http/ngx_http_request.c
++++ b/src/http/ngx_http_request.c
+@@ -425,6 +425,7 @@ ngx_http_init_request(ngx_event_t *rev)
+
+ clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+ c->log->file = clcf->error_log->file;
++ c->log->priority = clcf->error_log->priority;
+ if (!(c->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
+ c->log->log_level = clcf->error_log->log_level;
+ }
+@@ -1777,6 +1778,7 @@ found:
+
+ clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+ r->connection->log->file = clcf->error_log->file;
++ r->connection->log->priority = clcf->error_log->priority;
+
+ if (!(r->connection->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
+ r->connection->log->log_level = clcf->error_log->log_level;

0 comments on commit 9f12aea

Please sign in to comment.
Something went wrong with that request. Please try again.