Ubuntu log configuration

1. Create /etc/unbound/unbound.conf.d/logfile.conf.

server:
    # If no logfile is specified, syslog is used
    logfile: "/var/log/unbound.log"
    log-time-ascii: yes
    verbosity: 1

    #Level 0 means no verbosity, only errors
    #Level 1 gives operational information
    #Level 2 gives  detailed operational  information
    #Level 3 gives query level information
    #Level 4 gives  algorithm  level  information
    #Level 5 logs client identification for cache misses

2. Create /var/log/unbound.log.

sudo touch /var/log/unbound.log
sudo chown unbound:adm /var/log/unbound.log

3. Edit /etc/apparmor.d/local/usr.sbin.unbound to grant read write permission for /var/log/unbound.log.

# Site-specific additions and overrides for usr.sbin.unbound.
# For more details, please see /etc/apparmor.d/local/README.
/var/log/unbound.log rw,

4. Restart apparmor and unbound services.

sudo systemctl restart apparmor
sudo systemtel restart unbound

5. Create /etc/logrotate.d/unbound for log rotate.

/var/log/unbound.log {
    weekly
    rotate 7
    missingok
    notifempty
    compress
    delaycompress
    sharedscripts
    create 644
    postrotate
        /usr/sbin/unbound-control log_reopen
    endscript
}

Comments