CentOS   发布时间:2022-04-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了在CentOS 7.2上使用rsyslog配置syslog server大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

--=========准备======== 1.firewall状态检查 firewall-cmd --state 2.停止和禁用 systemctl stop firewalld.service systemctl disable firewalld.service 3.检查服务 systemctl status firewalld.service 4.检查iptables systemctl


--=========准备========

1.firewall状态检查
firewall-cmd --state

2.停止和禁用
systemctl stop firewalld.service
systemctl disable firewalld.service

3.检查服务
systemctl status firewalld.service

4.检查iptables
systemctl status iptables.service
systemctl stop iptables.service


--==========配置=========

1.打开配置文件
vim /etc/rsyslog.conf

2.启用rsyslog从UDP 514端口接收日志
$ModLoad imudp
$UDPServerRun 514

3.启用rsyslog从TCP 514端口接收日志
$ModLoad imtcp
$InputTCPServerRun 514

4.创建一个日志接收模板

在GLOBAL DIRECTIVES块前,加入
$template RemoteLogs,"/var/log/%HOSTNAME%/%PROGRAmname%.log" *
*.* ?RemoteLogs

备注:
The "& ~" sign represents a redirect rule,and is used to tell rsyslog daemon to stop processing log messages further,and not write them locally. If this redirection is not used,all the remote messages would be also written on local log files besides the log files described above,which means they would practically be written twice. Another consequence of using this rule is that the syslog server's own log messages would only be written to deDicated files named after machine's hostname.

加入规则:
#记录所有日志类型的info级别以及大于info级别的信息,但是mail邮件信息,authpriv验证方面的信息和cron时间任务相关的信息除外
*.info,mail.none,authpriv.none,cron.none ?RemoteLogs

5.
systemctl restart rsyslog

6.netstat -tulpn | grep rsyslog

大佬总结

以上是大佬教程为你收集整理的在CentOS 7.2上使用rsyslog配置syslog server全部内容,希望文章能够帮你解决在CentOS 7.2上使用rsyslog配置syslog server所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。