Tuesday, February 10, 2009

Working with Pound and Logging

One of the most frustrating parts of the Pound reverse proxy has been getting the logging to work.
The man page indicates that you can direct to standard output for testing, but that means you lose the logging once you close the terminal. Not good for production.

So I struggled to find a better option for our production environment: OSX 10.4.

My first thought was to leave the pound configuration set to log to std out, and send the std out and std err to a file. That looked like this:

#the pound.cfg file:
LogLevel 2
LogFacility -

# make a file to log to
root# touch /var/tmp/pound.log

#make it writeable
root# chmod ugo+rw pound.log

# run pound with output redirection
root# pound -v -f pound.cfg >> /var/tmp/pound.log 2>&1

--But surprisingly, that didn't work well. A few lines made it into the log, then no more. Odd. Gremlins.
So I did it the right way: through the syslogd facilities.
Pound (and lots of other daemons) can direct stdout and stderr to the syslogd, and each daemon can tag it's own messages with two bits of info: a 'Facility' and a 'severity'. The Facility is just a name.

So in the pound.cfg file, set the LogFacility. local4 is a name I made up. It could be "pound4" instead.
#the pound.cfg file:
LogLevel 2
LogFacility local4

Now configure the syslogd to actually listen for the pound logging on local4 by editting the /etc/syslog.conf, and adding this line:

local4.* /var/log/pound.log

Which tells syslogd to listen to all messages from local4 and direct them to the file at /var/log/pound.log.

Next step - restart the syslogd so it rereads the config file. On the Mac you do this by unloading it's plist and then reloading it.

root# launchctl unload /System/Library/LaunchDaemons/com.apple.syslogd.plist
root# launchctl load /System/Library/LaunchDaemons/com.apple.syslogd.plist

And monitor the pound.log:
root# tail-50f /var/log/pound.log

And get.... not much. Turns out that the default filter on the syslogd doesn't show the debug level needed to see the pound messages.

check your level like this:
root# syslog -c 0

It probably says:
Master filter mask: Off

Meaning that the master override filter is not doing anything.
Turn it all the way up temporarily to see the logging messages:

root# syslog -c 0 -d

which turns on the debug level of logging.
Now you should see your pound logging - assuming pound is running now and something is generating traffic.

After it all looks good you should turn off the master filter, and configure a facility
filter just for pound.

Check the syslogd man page....
man syslogd

1 comment:

  1. what's the command to turn off syslog debugging?

    ReplyDelete