linux rsyslog日志采集格式设定三

linux rsyslog日志采集格式设定三

1.创建日志接收模板

打开/etc/rsyslog.conf文件,在GLOBAL DIRECTIVES模块下任意位置添加以下内容

命令:

vim /etc/rsyslog.conf

测试:rsyslog.conf文件结尾添加以下内容

$template ztj,"%fromhost-ip% %app-name% %syslogseverity% %msg%\n"
:fromhost-ip,isequal,"127.0.0.1" /var/log/ztj.log;ztj

$template ztj,"%fromhost-ip% %app-name% %syslogseverity% %msg%\n"

#定义模板ztj

#fromhost-ip:日志中的主机IP地址

#app-name:产生日志的进程名称,其值与%programname%值相同

#syslogseverity:日志级别,以数字显示

#msg:日志内容

\n:换行

 #可以通过man rsyslog.conf命令查看rsyslog属性

[root@rhel77 ~]# man rsyslog.conf
...... 
Available Properties
       msg    the MSG part of the message (aka "the message" ;))

       rawmsg the message exactly as it was received from the socket. Should be useful for debugging.

你可能感兴趣的:(linux,rsyslog,linux,运维,服务器,rsyslog)