如何在系统日志中禁用logstash错误日志记录

unftdfkk  于 2023-09-28  发布在  Logstash
关注(0)|答案(3)|浏览(240)

所有Logstash错误都记录在/var/log/logstash/* 中,但Logstash的所有错误日志也记录在/var/log/syslog中。有什么方法可以在/var/log/syslog中禁用Logstash的日志记录错误吗?

t8e9dugd

t8e9dugd1#

我假设你从systemd运行logstash。由于未知原因,logstash打印它的日志在stdout/stderr上,所以journald将控制台输出转发到syslog。重定向systemd单元文件中的stdout/err,如下所示:

  1. [Service]
  2. Type=simple
  3. Restart=always
  4. WorkingDirectory=/data/logstash
  5. 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"

然后

  1. systemctl daemon-reload

  1. systemctl stop logstash.service
  2. systemctl start logstash.service
yjghlzjz

yjghlzjz2#

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

  1. StandardOutput=null
  2. StandardError=null
  1. # cat /etc/systemd/system/logstash.service
  2. [Unit]
  3. Description=logstash
  4. [Service]
  5. Type=simple
  6. User=logstash
  7. Group=logstash
  8. # Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.
  9. # Prefixing the path with '-' makes it try to load, but if the file doesn't
  10. # exist, it continues onward.
  11. EnvironmentFile=-/etc/default/logstash
  12. EnvironmentFile=-/etc/sysconfig/logstash
  13. ExecStart=/usr/share/logstash/bin/logstash "--path.settings" "/etc/logstash"
  14. StandardOutput=null
  15. StandardError=null
  16. Restart=always
  17. WorkingDirectory=/
  18. Nice=19
  19. LimitNOFILE=16384
  20. # When stopping, how long to wait before giving up and sending SIGKILL?
  21. # Keep in mind that SIGKILL on a process can cause data loss.
  22. TimeoutStopSec=infinity
  23. [Install]
  24. WantedBy=multi-user.target

那么当然

  1. #systemctl daemon-reload
  2. #systemctl restart logstash
展开查看全部
wn9m85ua

wn9m85ua3#

打开/etc/logstash/log4j2.properties并注解掉此行

  1. rootLogger.appenderRef.console.ref = ${sys:ls.log.format}_console

相关问题