Monday, July 21, 2008

Howto tell pound to log into its own logfile - pound.log

Ever wondered around why pound is logging into /var/log/syslog by default? I did. After some hours of searching around in the web for some solutions how to teach pound to log in its own logfile without finding anyhting, i needed to do some.

After some research i found the proper solution. My explanation will depend on a ubuntu 8.04 LTS Server.

Normally, sysklogd will overtake all messages from pound and will put them into syslog as anything with the facility 'daemon' goes in there by default. So first you need to change the LogFacility of pound as it is 'daemon' by default.

Just edit your /etc/pound.conf as follows:

#facility local0 is needed as sysklogd will
#seperate pound messages by this facility
LogFacility local0
LogLevel 3

And the change your /etc/syslog.conf

# log all (auth and such) to /var/log/syslog
# except messages with the facility local0 (pound)
#
*.*;auth,authpriv.none,local0.none -/var/log/syslog

# get the messages with the facility local0 and
# log them into the pound logfile
local0.* -/var/log/pound.log

The next step is to make sure that there is always a pound.log present. Therefore you need to modify the start script by adding a short conditional block into the top section of /etc/init.d/pound.

# Check if the pound.log exists, if not create one
if [ ! -e "/var/log/pound.log" ]
then
log_warning_msg "There is no pound.log, i'll create one"

touch /var/log/pound.log
chmod 0644 /var/log/pound.log
chown syslog:adm /var/log/pound.log
/etc/init.d/sysklogd reload > /dev/null
else
log_success_msg "pound.log was found"
/etc/init.d/sysklogd reload > /dev/null
fi

After you reloaded the sysklogd by /etc/init.d/sysklogd reload and restarted the pound, you should see the first log entries.

In my case the logfile increased to a size of more than 900 Mbyte after 24 hours, so don't forget to rotate the log. This could be done like this (/etc/logrotate.d/pound)

/var/log/pound.log {
daily
missingok
rotate 14
dateext
compress
notifempty
create 0644 syslog adm
postrotate
/etc/init.d/sysklogd reload > /dev/null
endscript
}

bohboh,
kratediggah

No comments: