rsyslog默认只可以传送系统的日志,比如DHCP,cron等,现在要传送一个服务的日志到远端的rsyslog服务器,该怎么实现呢?
解决方法:要使用rsyslog的imfile模块。
参考官方url:http://www.rsyslog.com/doc/v8-stable/configuration/modules/imfile.html
参考网上url:http://www.tuicool.com/articles/Jv2eUvn
rsyslog的配置文件(过滤掉了注释的内容):
[[email protected] ~]# cat /etc/rsyslog.conf | egrep -v "#|^$"
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
$IncludeConfig /etc/rsyslog.d/*.conf
*.info;mail.none;authpriv.none;cron.none /var/log/messages
authpriv.* /var/log/secure
mail.* -/var/log/maillog
cron.* /var/log/cron
*.emerg *
uucp,news.crit /var/log/spooler
local7.* /var/log/boot.log
$ModLoad imfile
$InputFileName /usr/local/pf/logs/packetfence.log
$InputFileTag packetfence:
$InputFileSeverity info
$InputFileStateFile stat-packetfence
$InputFileFacility local5
$InputFilePollInterval 1
$InputFilePersistStateInterval 1
$InputRunFileMonitor
local5.* @10.64.41.223:514
[[email protected] ~]#
修改完配置文件,重启服务
[[email protected] ~]# /etc/init.d/rsyslog restart
Shutting down system logger: [ OK ]
Starting system logger: [ OK ]
[[email protected] ~]#
红色字体是为了传送/usr/local/pf/logs/packetfence.log到10.64.41.223:514而新加的配置。