Syslog: added "nohostname" option. The option disables sending hostname in the syslog message header. This is useful with syslog daemons that do not expect it (tickets #677 and #783).
diff --git a/src/core/ngx_syslog.c b/src/core/ngx_syslog.c index d4e79f6..08f4c04 100644 --- a/src/core/ngx_syslog.c +++ b/src/core/ngx_syslog.c
@@ -194,6 +194,9 @@ peer->tag.data = p + 4; peer->tag.len = len - 4; + } else if (len == 10 && ngx_strncmp(p, "nohostname", 10) == 0) { + peer->nohostname = 1; + } else { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "unknown syslog parameter \"%s\"", p); @@ -220,6 +223,11 @@ pri = peer->facility * 8 + peer->severity; + if (peer->nohostname) { + return ngx_sprintf(buf, "<%ui>%V %V: ", pri, &ngx_cached_syslog_time, + &peer->tag); + } + return ngx_sprintf(buf, "<%ui>%V %V %V: ", pri, &ngx_cached_syslog_time, &ngx_cycle->hostname, &peer->tag); }
diff --git a/src/core/ngx_syslog.h b/src/core/ngx_syslog.h index a915051..cc4c842 100644 --- a/src/core/ngx_syslog.h +++ b/src/core/ngx_syslog.h
@@ -16,7 +16,8 @@ ngx_addr_t server; ngx_connection_t conn; - ngx_uint_t busy; /* unsigned busy:1; */ + unsigned busy:1; + unsigned nohostname:1; } ngx_syslog_peer_t;