Mercurial > hg > nginx
changeset 6286:a6a2016b8e31
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).
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Mon, 26 Oct 2015 19:06:42 +0300 |
parents | 1f26bf65b1bc |
children | 4ccb37b04454 |
files | src/core/ngx_syslog.c src/core/ngx_syslog.h |
diffstat | 2 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/ngx_syslog.c Tue Oct 27 23:16:35 2015 +0300 +++ b/src/core/ngx_syslog.c Mon Oct 26 19:06:42 2015 +0300 @@ -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); }