如何在 syslog 中禁用 logstash 错误记录

How to Disable logstash error logging in syslog

所有 Logstash 错误记录在 /var/log/logstash/* ,但 Logstash 所有错误日志也记录在 /var/log/syslog 。 在 /var/log/syslog?

中有什么方法可以禁用 Logstash 的日志记录错误

我想你 运行 来自 systemd 的 logstash。由于未知原因,logstash 在 stdout/stderr 上打印它的日志,因此 journald 将控制台输出转发到系统日志。 像这样在 systemd 单元文件中重定向 stdout/err:

[Service]
Type=simple
Restart=always
WorkingDirectory=/data/logstash
ExecStart=/usr/bin/sudo -u logstashuser bash -c "/opt/logstash/bin/logstash --path.settings /opt/logstash/conf >/dev/null 2>/logs/logstash/logstash.error.log"

然后

systemctl daemon-reload 

systemctl stop logstash.service
systemctl start logstash.service

另一个解决方案是修改 /etc/systemd/system/logstash.service 并将这两个选项更改如下

StandardOutput=null
StandardError=null
# cat /etc/systemd/system/logstash.service
[Unit]
Description=logstash

[Service]
Type=simple
User=logstash
Group=logstash
# Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.
# Prefixing the path with '-' makes it try to load, but if the file doesn't
# exist, it continues onward.
EnvironmentFile=-/etc/default/logstash
EnvironmentFile=-/etc/sysconfig/logstash
ExecStart=/usr/share/logstash/bin/logstash "--path.settings" "/etc/logstash"
StandardOutput=null
StandardError=null
Restart=always
WorkingDirectory=/
Nice=19
LimitNOFILE=16384

# When stopping, how long to wait before giving up and sending SIGKILL?
# Keep in mind that SIGKILL on a process can cause data loss.
TimeoutStopSec=infinity

[Install]
WantedBy=multi-user.target

那当然

#systemctl daemon-reload
#systemctl restart logstash