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 complicated.

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

*.* remote.log.host

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 only.
    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 this:

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 remote.host.tld -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 ?


Adding ld->udpaddr.sin_family =AF_INET; to svlogd.c


FreeBSD patch: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=207747


--- src/svlogd.c.orig   2016-03-06 13:48:35 UTC
+++ src/svlogd.c
@@ -430,6 +430,7 @@ unsigned int logdir_open(struct logdir *
   ld->name =(char*)fn;
   ld->ppid =0;
   ld->match ='+';
+  ld->udpaddr.sin_family =AF_INET;
   ld->udpaddr.sin_port =0;
   ld->udponly =0;
   while (! stralloc_copys(&ld->prefix, "")) pause_nomem();

UPDATE: As an alternative to this problem currently using https://immortal.run

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.