Question regarding newsyslog.conf and Bind logs

Richard T.A. Neal richard at richardneal.com
Thu Aug 25 20:46:21 UTC 2022


J wrote:

> I'm looking to have my: queries.log (which logs all the queries my Bind
> 9.16.30 recursive resolver resolves), rotated at the end of the day and I'd like to keep 7 days worth of those logs.
   {snip}
> I still want any daily log *before* it's being rotated to be a maximum size of 1 GB.

Hi J,

I'm coming a little late to the party on this one and I think you might struggle to do rotation based on both date/time *and* file size, but I use logrotate to rotate all of my BIND logs daily, keeping 31 days of logs. And you'll see that one of the last things that logrotate does is to call [rndc reconfig] which causes BIND to generate fresh log files in place of the rotated ones.

My BIND logging itself is setup based largely on the configuration described here:
https://kb.isc.org/docs/aa-01526

My logrotate.conf file then looks like this the following, which itself is based on this:
https://ixnfo.com/en/logrotate-bind9.html

#-----------------------------------------
# RTAN BIND 9 daily log rotation
#
# Note that the log file won't rotate until at least one day AFTER you set this for the first time.
# Eg if you create this file on a Wednesday then they won't rotate for the first time until THURSDAY night:
# https://serverfault.com/questions/375004/logrotate-not-rotating-the-logs
#-----------------------------------------

/var/log/named/*.log
{
  olddir /var/log/named/archived
  compress
  create 0644 bind bind
  daily
  dateext
  missingok
  notifempty
  rotate 31
  sharedscripts
  postrotate
    /usr/sbin/rndc reconfig > /dev/null 2>/dev/null || true
  endscript
}
#-----------------------------------------

Best,
Richard.


More information about the bind-users mailing list