How to growl be used with syslog

growl

I have a shell script that logs messages to syslog using the 'logger' command. In my syslog.conf, I filter those messages to a specific log file. This is a portable solution that works across all unices. On OS X, I would also like to have these messages sent to growl. I have tried both of the following with no success:

*.*        |exec /usr/local/bin/growlnotify
*.*        @127.0.0.1:23052

Best Answer

According to man syslog.conf, Mac OS X's syslog.conf can handle messages only by writing to a file, sending to a remote host's syslog, and send them to users' consoles.


Your best option is probably to send to a file, and write a daemon or a periodically running script that consumes this file and calls growlnotify with what it reads from the file, something like the following:

#!/usr/bin/env bash
while read line
do
    /usr/local/bin/growlnotify "Your App" -m "$line"
done < /path/to/file
echo -n > /path/to/file

Either keep this running all the time by wrapping in a loop, or start it every few seconds using a launchd job and the StartInterval directive. man launchd and man launchd.plist can help you here.