How to make svlogd send logs via UDP

From: Nicolas de Bari Embriz Garcia Rojas <>
Date: Thu, 4 Feb 2016 15:11:27 +0100

I am currently using runit + svlogd <> for
supervising some applications, but when deploying to multiple machines, I
have the need to centralize/unify the logs in a single place in order to
simplify things, otherwise login to each machine makes things very

Instead of sending all the host logs via syslog with something like:


I would like to only send the logs related to the application, in theory
svlogd is capable of doing this, from the docs

    tells svlogd to transmit the first len characters of selected log
messages to the IP address a.b.c.d, port number port. If port isn’t
set, the default port for syslog is used (514). len can be set through
the -l option, see below. If svlogd has trouble sending udp packets,
it writes error messages to the log directory. Attention: logging
through udp is unreliable, and should be used in private networks
    is the same as the u line above, but the log messages are no
longer written to the log directory, but transmitted through udp only.
Error messages from svlogd concerning sending udp packages still go to
the log directory.

The content of my config file /service/my-service/log/main/config:




For testing I created a very basic UDP server/client
<>, but for an unknown
reason svlogd is not sending the logs, I also give a try with netcat using

nc -ul 5514

The log run script I am using for this /service/my-service/log/run:


exec svlogd -tt ./main

The only error message I get is:

warning: failure sending through udp:

A work around I have been using is to call logger within the log run
script, something like:


exec chpst -u nobody logger -i -h -P 42060 -t my-app

But with this approach I lose all the advantage of svlogd besides the sv
status . is always on/off (1,0) since logger don't run like daemon.

At the end I would like to continue having the logs from svlogd but been
available to make work the ua.b.c.d[:port] option.

*Update*: Doing a ktrace this is what I get:

  4909 svlogd CALL socket(PF_INET,SOCK_DGRAM,IPPROTO_IP)
  4909 svlogd RET socket 7
  4909 svlogd CALL fcntl(0x7,F_GETFL,0)
  4909 svlogd RET fcntl 2
  4909 svlogd CALL fcntl(0x7,F_SETFL,0x6<O_RDWR|O_NONBLOCK>)
  4909 svlogd RET fcntl 0
  4909 svlogd CALL sendto(0x7,0x609580,0x3c,0,0x609c3c,0x10)
  4909 svlogd STRU struct sockaddr { AF_UNSPEC, unknown address family }
  4909 svlogd RET sendto -1 errno 47 Address family not supported
by protocol family
  4909 svlogd CALL write(0x6,0x609760,0x62)
  4909 svlogd GIO fd 6 wrote 98 bytes
       "warning: failure sending through udp:

STRU struct sockaddr { AF_UNSPEC, unknown address family }

Any ideas ?
Received on Thu Feb 04 2016 - 14:11:27 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:44:19 UTC