0

I wonder what's the recommended way to rotate PowerDNS log files. I added the following entry to logrotate:

# cat /etc/logrotate.d/pdns 
/var/log/pdns/*.log {
    daily
    rotate 7
    compress
    delaycompress
}

- but it looks like PowerDNS doesn't accept the signals from logrotate and it's referring the old log file:

# lsof | grep "pdns.log*"
rsyslogd  17776    root    5w      REG              253,0      88273     785738 /var/log/pdns/pdns.log-20140728

There are two available methods:

1. The copytruncate option but then there is a warning that some logging data might be lost.

copytruncate
              Truncate the original log file in place after creating a copy,
              instead of moving the old log file and optionally creating a
              new one.

2. The postrotate script. It seems that a full restart is required because reload (pdns_control cycle) and kill HUP are also ignored - with this method PowerDNS will be unavailable for a short period of time.

postrotate
        /sbin/service pdns reload > /dev/null 2>/dev/null || true
    endscript

Q1. Is there a better method to avoid potential logging data lost or the need to do a full restart?

Details:

- System: CentOS 6x

- Version: pdns-3.3.1 - related options

/etc/pdns/pdns.conf
...
log-dns-queries=yes
loglevel=5
logging-facility=6
...

Edit:

It's strange but I also noticed that it works fine with default logging-facility to system log /var/log/messages.

HTF
  • 3,050
  • 14
  • 49
  • 78
  • I'm trying to do as explained on this site: https://visei.com/2011/10/how-to-prevent-cron-powerdns-clogging-syslog/ –  Sep 26 '16 at 20:59

1 Answers1

2

PowerDNS logs to the local syslog, so it is the syslog daemon you need to send a HUP signal to when you rotate the log files. You do not need to signal PowerDNS at all.

For example (taken from the logrotate configuration for rsyslog):

/var/log/pdns/*.log {
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940