首页 > 代码库 > rsyslog local0-local7的用法

rsyslog local0-local7的用法

很多时候我们需要将一个服务的日志文件导向一个指定的文件,这个时候可以设置log-facility 如在dhcpd.conf中配置

1 : update log-facility in the dhcpd.conf file 

[root@lab ~]# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#   see ‘man 5 dhcpd.conf‘
#
# dhcpd.conf
# #
log-facility local2;
default-lease-time 600;
 max-lease-time 7200;
#
# # If this DHCP server is the official DHCP server for the local
# # network, the authoritative directive should be uncommented.
 authoritative;
#
#
 allow booting;
 allow bootp;
 ddns-update-style interim;
#
# # Standard configuration directives...
#
subnet 192.168.0.0 netmask 255.255.255.0 {

        next-server 192.168.0.254;
        option routers 192.168.0.254;
        range 192.168.0.200 192.168.0.240;
#       option domain-name-servers 9.186.182.1;
        filename "pxelinux.0";

  }




2: update /etc/rsyslog.conf file
# Save boot messages also to boot.log
local7.*                                                /var/log/boot.log
local2.*                                                /var/log/dhcpd.log



问题是重启上面两个服务器,注意先让rsyslog生效再重启dhcp服务

发现/var/log/message 和dhcpd.log中都会生成日志

rsyslog local0-local7的用法