无法将 DHCPD 日志与 syslog 分开

无法将 DHCPD 日志与 syslog 分开

我正在尝试将 DHCPD 日志syslog与 Ubuntu 16.4 LTS 中的文件分离。

在我的dhcpd.conf文件中我添加了:

log-facility local7;

rsyslog.conf文件中:

#Logging for DHCP service
local7 /var/log/dhcp/dhcp.log

我已经创建了dhcp文件夹和dhcp.log文件。

是权限问题吗?

答案1

将此添加到规则部分rsyslog.conf或如果存在于/etc/rsyslog.d/50-default.conf

添加"local7 /var/log/dhcp/dhcp.log"

###############
#### RULES ####
###############

#
# First some standard log files.  Log by facility.
#

if $programname == 'dhcpd' then /var/log/dhcp.log
& stop

然后打开/etc/logrotate.d/rsyslog并添加/var/log/dhcp.log如下内容

/var/log/syslog
/var/log/dhcp.log
{
        rotate 7
        daily
        missingok
        notifempty
        delaycompress
        compress
        postrotate
                invoke-rc.d rsyslog rotate > /dev/null
        endscript
}

如果你想每天轮流

或者像这样

/var/log/kern.log
/var/log/auth.log
/var/log/user.log
/var/log/lpr.log
/var/log/cron.log
/var/log/debug
/var/log/messages
/var/log/dhcp.log
{
        rotate 4
        weekly
        missingok
        notifempty
        compress
        delaycompress
        sharedscripts
        postrotate
                invoke-rc.d rsyslog rotate > /dev/null
        endscript
}

如果你想每周轮换

相关内容