可以通过使用 syslog-ng等工具来向多个服务器发送NGINX日志。

以下是一些可能的步骤:

  1. 安装syslog-ng

在Ubuntu上,可以使用以下命令来安装syslog-ng:

sudo apt-get install syslog-ng

  1. 编辑syslog-ng.conf文件

在Ubuntu上,syslog-ng.conf文件位于/etc/syslog-ng/syslog-ng.conf。

在文件中添加以下行来将NGINX日志发送到多个服务器:

destination d_server1 {tcp("server1.example.com" port(514));}; destination d_server2 {tcp("server2.example.com" port(514));}; log {source(s_src); destination(d_server1); destination(d_server2);};

在上面的例子中,将NGINX日志发送到server1.example.com和server2.example.com的514端口。

  1. 重启syslog-ng

在Ubuntu上,可以使用以下命令重新启动syslog-ng:

sudo service syslog-ng restart

  1. 配置NGINX日志

在NGINX配置文件中,可以添加以下行将日志发送到syslog:

access_log syslog:server=localhost,facility=local7,tag=nginx_access; error_log syslog:server=localhost,facility=local7,tag=nginx_error;

在上面的例子中,将NGINX访问日志和错误日志发送到本地syslog的local7设施。

可以根据需要修改上述配置,以便将NGINX日志发送到多个服务器

NGINX SYSLOG 同时发个多个SERVER

原文地址: https://www.cveoy.top/t/topic/hc8j 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录