所有Logstash错误都记录在/var/log/logstash/* 中,但Logstash的所有错误日志也记录在/var/log/syslog中。有什么方法可以在/var/log/syslog中禁用Logstash的日志记录错误吗?
t8e9dugd1#
我假设你从systemd运行logstash。由于未知原因,logstash打印它的日志在stdout/stderr上,所以journald将控制台输出转发到syslog。重定向systemd单元文件中的stdout/err,如下所示:
[Service]Type=simpleRestart=alwaysWorkingDirectory=/data/logstashExecStart=/usr/bin/sudo -u logstashuser bash -c "/opt/logstash/bin/logstash --path.settings /opt/logstash/conf >/dev/null 2>/logs/logstash/logstash.error.log"
[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.servicesystemctl start logstash.service
systemctl stop logstash.service
systemctl start logstash.service
yjghlzjz2#
另一种解决方案是修改/etc/systemd/system/logstash.service并将这两个选项更改为如下所示
/etc/systemd/system/logstash.service
StandardOutput=nullStandardError=null
StandardOutput=null
StandardError=null
# cat /etc/systemd/system/logstash.service[Unit]Description=logstash[Service]Type=simpleUser=logstashGroup=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/logstashEnvironmentFile=-/etc/sysconfig/logstashExecStart=/usr/share/logstash/bin/logstash "--path.settings" "/etc/logstash"StandardOutput=nullStandardError=nullRestart=alwaysWorkingDirectory=/Nice=19LimitNOFILE=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
# cat /etc/systemd/system/logstash.service
[Unit]
Description=logstash
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"
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
#systemctl daemon-reload
#systemctl restart logstash
wn9m85ua3#
打开/etc/logstash/log4j2.properties并注解掉此行
rootLogger.appenderRef.console.ref = ${sys:ls.log.format}_console
3条答案
按热度按时间t8e9dugd1#
我假设你从systemd运行logstash。由于未知原因,logstash打印它的日志在stdout/stderr上,所以journald将控制台输出转发到syslog。重定向systemd单元文件中的stdout/err,如下所示:
然后
和
yjghlzjz2#
另一种解决方案是修改
/etc/systemd/system/logstash.service
并将这两个选项更改为如下所示那么当然
wn9m85ua3#
打开/etc/logstash/log4j2.properties并注解掉此行