0

I'm on OSX running Mavericks 10.9.2. I'm trying to get my Revel app logging to syslog. My code is failing on this line:

sysLog, err := syslog.New(syslog.LOG_NOTICE|syslog.LOG_LOCAL0, "myApp")

with this error:

Unix syslog delivery error

Syslog is definitely running on my machine. What could be the problem?

Dmitri Goldring
  • 4,176
  • 2
  • 24
  • 28
l15a
  • 2,547
  • 5
  • 29
  • 41
  • Try checking /var/log/system.log to see if there was a more useful error than what Go gave you. You may also want to check out this [article](http://vastdevblog.vast.com/blog/2012/04/18/using-syslogappender-on-os-x/). – Dmitri Goldring Jul 31 '14 at 10:52
  • I'm successfully writing to syslog from another application. That article is for Java so didn't really apply. – l15a Jul 31 '14 at 18:34

1 Answers1

2

Verify syslog is running or else enable it.

$ ps -aux | grep syslog
root 11703  0.0  0.4 14424 1992  -  IsJ   9:17AM 0:00.01 /usr/sbin/syslogd -ss

Now verify syslog is running in the expected local address. The log/syslog package looks for syslog in /var/run/syslog or /dev/log. If it does not find it there, you see the "Unix syslog delivery error" as per http://golang.org/src/pkg/log/syslog/syslog_unix.go.

To find the local address of syslog use the sockstat command

$sockstat
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS      
root     login      12104 3  dgram  -> /var/run/logpriv  
root     login      11791 3  dgram  -> /var/run/logpriv
root     cron       11754 4  dgram  -> /var/run/logpriv
root     syslogd    11703 4  dgram  /var/run/log
root     syslogd    11703 5  dgram  /var/run/logpriv

In above case, syslog is running at /var/run/log. So, I created a symlink from /var/run/log to /var/log/syslog and the error goes away.

$ln -sf /var/run/log /var/run/syslog
Sid
  • 81
  • 1
  • 4
  • I'm on a Mac so I ran lsof -p. I got a lot of output but do see this: syslogd 10273 root 6u unix 0x4a2e6ea3c4e6ca4f 0t0 /var/run/syslog – l15a Aug 04 '14 at 23:59
  • Sorry, I don't have access to a Mac. Can you verify syslog is configured and working correctly, using the command `logger "Test message from logclient"`. It should write to a file in /var/log/ as configured in /etc/syslog.conf. – Sid Aug 05 '14 at 02:16
  • Syslog is definitely running on my machine. I can write to it manually and via a different application. – l15a Aug 05 '14 at 17:10