Logging
To setup logging in Bind 9 you will need to complete the following:
First configure logging in your named.conf.options file
sudo nano /etc/bind/named.conf.options
Add this at the bottom of the file:
logging {
channel b_query {
file "/var/log/named/query.log" versions 2 size 1m;
print-time yes;
severity info;
};
category queries { b_query; };
};
Now create a directory for the logs. Unless you edit your /etc/apparmor.d/usr.sbin.named, you will have to use the default directory of /var/log/named/:
sudo mkdir /var/log/named
sudo chown bind:bind /var/log/named
sudo touch /var/log/named/query.log
sudo chown bind:bind /var/log/named/query.log
Now restart Bind
sudo service bind9 restart
Statistics
To setup statistics in Bind 9 you will need to complete the following:
First configure statistics in your named.conf.options
sudo nano /etc/bind/named.conf.options
Add this line:
statistics-file "/var/cache/bind/named.stats";
Now run the following command:
sudo rndc stats
Now you need to restart Bind
sudo service bind9 restart