大网数据广告活动
服务器运维问答

how to filter rsyslog messages by tags

· 52CE 我爱测

I have several applications and scripts that I want to redirect the output to custom files. I launch those applications using command | logger -t TAG I would like to filter these messages based on their tags and redirect them to …

问题原文

原帖链接 · mistyrouge · CC BY-SA 3.0

I have several applications and scripts that I want to redirect the output to custom files.

I launch those applications using

command | logger -t TAG

I would like to filter these messages based on their tags and redirect them to different files. I don't want to use bash redirection as those applications are mainly long running process and need proper log rotation.

I have tried to add a custom filter in /etc/rsyslog.d/60-myfilter.conf ;

if $syslogtag == 'giomanager' then /var/log/giomanager.log

What am I doing wrong ? What is the proper way to filter based on the tag or is there a better option to have similar result?

已采纳解答

原帖链接 · mistyrouge · CC BY-SA 3.0

So I finally found a solution to my problem.

Thank you very much to @lain for leading my way.

The solution as stated before is to include a ':' in the tag name. Also, and this is very important, the file name must be before 50-default.conf in alphabetical order.

To resume, put the following in 30-giomanager.conf :

:syslogtag, isequal, "giomanager:" /var/log/giomanager.log
& stop

Note that the file /var/log/giomanager.log should be writable by the 'syslog' user.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-06-11)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。