Vladimir Homutov
October 27, 2015 10:16AM
On Fri, Oct 23, 2015 at 08:51:56PM +0200, Nils Hermansson wrote:
> # HG changeset patch
> # User Nils Hermansson <3tnica@gmail.com>
> # Date 1445625283 -7200
> # Fri Oct 23 20:34:43 2015 +0200
> # Node ID 868fc6b3bf69be611118c597578e749c65698b8c
> # Parent ee16fb0db905cfb858a929374cf623cdf1a0f9d3
> Most standard syslog facilicties do not expect hostname when logging to
> Unix Sockets.
> This patch removes hostname from syslog message when logging to Unix Socket.
> Tested on rsyslog and syslog-ng
>
> diff -r ee16fb0db905 -r 868fc6b3bf69 src/core/ngx_syslog.c
> --- a/src/core/ngx_syslog.c Tue Oct 20 21:28:38 2015 +0300
> +++ b/src/core/ngx_syslog.c Fri Oct 23 20:34:43 2015 +0200
> @@ -219,9 +219,17 @@
> ngx_uint_t pri;
>
> pri = peer->facility * 8 + peer->severity;
> -
> - return ngx_sprintf(buf, "<%ui>%V %V %V: ", pri,
> &ngx_cached_syslog_time,
> +#if (NGX_HAVE_UNIX_DOMAIN)
> + if (peer->server.sockaddr->sa_family == AF_UNIX) {
> + return ngx_sprintf(buf, "<%ui>%V %V: ", pri,
> &ngx_cached_syslog_time,
> + &peer->tag);
> + } else {
> +#endif
> + return ngx_sprintf(buf, "<%ui>%V %V %V: ", pri,
> &ngx_cached_syslog_time,
> &ngx_cycle->hostname, &peer->tag);
> +#if (NGX_HAVE_UNIX_DOMAIN)
> + }
> +#endif
> }

Hi Nils,

we agree that there is some inconvenience with local syslog and are
considering adding configuration option to select desired behaviour
at this place.

Note that there is a simple solution - to setup your syslog daemon
to expect hostname. See https://trac.nginx.org/nginx/ticket/677
and https://trac.nginx.org/nginx/ticket/783.

Your suggested patch would breaks existing setups and make message
content depend on transport, what is undesirable.

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Syslog Unix socket patch

Nils Hermansson 680 October 23, 2015 02:54PM

Re: Syslog Unix socket patch

Vladimir Homutov 397 October 27, 2015 10:16AM

Re: Syslog Unix socket patch

Nils Hermansson 418 October 27, 2015 02:28PM

Re: Syslog Unix socket patch

Nils Hermansson 460 October 27, 2015 03:22PM

Re: Syslog Unix socket patch

splitice 669 October 29, 2015 06:04AM

Re: Syslog Unix socket patch

Vladimir Homutov 475 October 29, 2015 06:22AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 314
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready