Categories
Uncategorized

Redirect dhcpd.log file to another file

In Centos 7 the dhcp log file is sent to /var/log/messages

This can be redirected to another file

emacs /etc/dhcp/dhcpd.conf

Replace this line

log-facility local7;

With this

log-facility local6;

Now modify /etc/rsyslog.conf

emacs /etc/rsyslog.conf

Add this line right after local7.*

# Redirect dhcpd log messages to another logfile
local6.*                                                /var/log/dhcpd/dhcpd.log

Modify this line

# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none                /var/log/messages

With this

*.info;mail.none;authpriv.none;cron.none;local6.none                /var/log/messages

So you only appended ;local6.none

Create the new directory where the new dhcp log file will be stored

mkdir /var/log/dhcpd

Now restart rsyslog

systemctl restart rsyslog