|
|
参考链接:
官网:
http://www.rsyslog.com/storing-messages-from-a-remote-system-into-a-specific-file/
http://www.rsyslog.com/sending-messages-to-a-remote-syslog-server/
师父:
http://debugo.com/linux-note-rsyslog/
- 安装rsyslog
- 编辑/etc/rsyslog.conf: 打开UDP、TCP监听
- 创建/etc/rsyslog.d/remoteserver.conf(写在这个文件中的规则,放在/etc/rsyslog.conf中也可生效。分文件是便于管理)
- 可用规则1:为每一个主机(IP)配规则
1
| :fromhost,isequal, “debugo02″ /var/log/remoteserver.log
|
- 可用规则2:为一个IP Group配规则
1
2
3
4
5
6
7
8
9
| $ModLoad imtcp
$InputTCPServerRun 10514
# do this in FRONT of the local/regular rules
if $fromhost-ip startswith '192.0.1.' then /var/log/network1.log
& ~
if $fromhost-ip startswith '192.0.2.' then /var/log/network2.log
& ~
# local/regular rules, like
*.* /var/log/syslog.log
|
- 重启rsyslog服务:service rsyslog restart
- 安装rsyslog
- 编辑/etc/rsyslog.conf: 将remote host行取消注释并填入rsyslog server IP:
1
2
| # remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
*.* @@remote_server_ip:514
|
- 测试:logger "hello world"。根据server端配置路径查看日志内容。
待更新:添加logrotate
|
|