Skip to main content

syslog-ng & MacOS X

MacOS X still ships with good ol' syslogd which may suffice for most of us but I still prefer syslog-ng. Luckily MacPorts ships syslog-ng - unfortunately compilation fails with:

ranlib: file: libsyslog-ng.a(afsql.o) has no symbols
ranlib libsyslog-ng.a
ranlib: file: libsyslog-ng.a(afsql.o) has no symbols
if /usr/bin/gcc-4.0 -DHAVE_CONFIG_H -I. -I. -I..  \
  -I/opt/local/include \
  -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include \
  -I/opt/local/include   -I/opt/local/include/eventlog \
  -DHAVE_SOCKADDR_SA_LEN -DLIBNET_BSDISH_OS \
  -DLIBNET_BSD_BYTE_SWAP  -D_GNU_SOURCE \
  -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \
  -O2 -Wall -MT main.o -MD -MP -MF ".deps/main.Tpo" \
  -c -o main.o main.c; \
        then mv -f ".deps/main.Tpo" ".deps/main.Po"; \
  else rm -f ".deps/main.Tpo"; exit 1; fi
/usr/bin/gcc-4.0  -O2 -Wall  -L/opt/local/lib -o syslog-ng \
    main.o libsyslog-ng.a -lresolv  -lfl -L/opt/local/lib \
   -lglib-2.0 -lintl -liconv   -L/opt/local/lib -levtlog   -lnet \
   -lwrap 
Undefined symbols:
  "_configuration", referenced from:
      _configuration$non_lazy_ptr in libsyslog-ng.a(cfg.o)
      _configuration$non_lazy_ptr in libsyslog-ng.a(cfg-grammar.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
The compilation will succeed when we specify globals.o explicitly on the command line, but I wanted to take this opportunity to try a newer version of syslog-ng, the MacPorts way:
$ mkdir -p ~/.ports/sysutils/syslog-ng
$ cd ~/.ports
$ cp $macports/release/ports/sysutils/syslog-ng/Portfile sysutils/syslog-ng/
$ egrep '^version|master_sites|checksums' sysutils/syslog-ng/Portfile 
version           3.0.4
master_sites   http://www.balabit.com/downloads/files/syslog-ng/sources/3.0.4/source/
checksums      md5 86c39779261545d2289e9c309e262b8d
$ portindex
$ port clean --all syslog-ng
$ port install syslog-ng
Well, even the latest version will fail, so we fix it ourselves:
$ cd sysutils/syslog-ng/work/syslog-ng-3.0.4/src/
$ gcc  -O2 -Wall  -L/opt/local/lib -o syslog-ng globals.o main.o \
       libsyslog-ng.a -lfl -L/opt/local/lib -lglib-2.0 -lintl -liconv \
       -L/opt/local/lib -levtlog -L/opt/local/lib -lssl -lcrypto \
       -lz  -lz -lnet -lwrap  -lresolv
$ cd -
$ port install syslog-ng
The MacPorts install provides a hint how to (disable Apple's syslogd and) enable syslog-ng:
$ launchctl unload -w /System/Library/LaunchDaemons/com.apple.syslogd.plist
$ launchctl load   -w /Library/LaunchDaemons/org.macports.syslog-ng.plist
However, when doing this, syslog-ng is started over and over again, as if launchd doesn't recognize it as "already running" and respawns it all the time. No good :(