默认情况下,Rsyslog安装在Ubuntu 18.04服务器上。如果没有安装,您可以通过运行以下命令来安装它:
apt install rsyslog -y
服务端
vim /etc/rsyslog.conf
module(load=“imtcp”)
input(type=“imtcp” port=“514”)
$AllowedSender TCP, 127.0.0.1, 192.168.0.0/24, *.example.com
t
e
m
p
l
a
t
e
r
e
m
o
t
e
−
i
n
c
o
m
i
n
g
−
l
o
g
s
,
"
/
自
己
定
义
的
路
径
信
息
/
template remote-incoming-logs,"/自己定义的路径信息/%
templateremote−incoming−logs,"/自己定义的路径信息/year%/%
m
o
n
t
h
month%/%
monthday%/%HOSTNAME%/%PROGRAMNAME%.log"
. ?remote-incoming-logs
其他变量包括:
%syslogseverity%, %syslogfacility%, %timegenerated%, %HOSTNAME%, %syslogtag%, %msg%, %FROMHOST-IP%, %PRI%, %MSGID%, %APP-NAME%, %TIMESTAMP%, %
y
e
a
r
year%, %
yearmonth%, %$day%
Chown -R syslog:root 日志存储路径
rsyslogd -f /etc/rsyslog.conf -N1
正常结果如下:
rsyslogd: version 8.32.0, config validation run (level 1), master config /etc/rsyslog.conf
rsyslogd: End of config validation run. Bye.
systemctl restart rsyslog
Netstat -pantu | grep 514
root@aibee:/varlog/log# netstat -pantu | grep rsyslog
tcp 0 0 0.0.0.0:514 0.0.0.0:* LISTEN 30029/rsyslogd
vim /etc/rsyslog.conf
. @@ip地址
参考链接:
https://blog.csdn.net/weixin_28312391/article/details/112633464
https://www.ywnz.com/linuxyffq/4329.html