我正在尝试将 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
}
如果你想每周轮换