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

How to tell syslog-ng to ignore source files if they are absent

· 52CE 我爱测

I'm trying to deploy a standard configuration file for syslog-ng on multiple linux servers. My infrastructure includes many services (apache, confluence, ...) with log file located at various places. See the excerpt of my custom …

问题原文

原帖链接 · Suffren · CC BY-SA 4.0

I'm trying to deploy a standard configuration file for syslog-ng on multiple linux servers. My infrastructure includes many services (apache, confluence, ...) with log file located at various places.

See the excerpt of my custom syslog-ng config file :

source s_auditd {
  file("/var/log/audit/audit.log" flags(no-parse) program-override("auditd"));
};

source s_app {
  file("/opt/atlassian/confluence/logs/catalina.out" flags(no-parse) program-override("confluence"));
  file("/opt/atlassian/jira/logs/catalina.out" flags(no-parse) program-override("jira"));
};

My config file could be deployed on servers that are not hosting confluence for example. But syslog-ng will try to look for log file I declared into my source s_app anyway and going to throw errors.

My question is simple : is there a mechanism where I can tell syslog-ng to ignore absent log file ?

Thanks

已采纳解答

原帖链接 · HBruijn · CC BY-SA 4.0

IMHO you're approaching this the wrong way around.

Rather than monolithic configuration that must include everything, go for a minimal universal config, that leverages the dynamic loading of external configuration files/snippets from a drop-in directory:

@include "/path/to/syslog-ng.conf.d/"

That minimal config can be deployed everywhere and will always work, while you add system/role specific syslog-ng configuration sections as drop-in files, one for each role/service that gets installed on that particular server. That is something which is easily managed by whatever deployment and/or configuration management solution that is employed at your site and also the approach that most distributions are taking for a plethora of tools.

When you deploy for example Confluence, also deploy a /path/to/syslog-ng.conf.d/confluence.conf with the specific additional configuration that is required to monitor Confluence on that host.

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

资料来源与适用范围

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

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

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