Nginx

在 CentOS 7 上將 nginx 記錄到系統日誌

  • August 1, 2016

全新安裝 CentOS 7 和 nginx 1.6.3。根據官方文件,我將 access_log 指令設置為通過 syslog 轉發到 /etc/nginx/nginx.conf 中的遠端伺服器:

#access_log /var/log/nginx/access.log   main;
access_log syslog:server=[10.1.2.3],facility=local7,tag=nginx,severity=info;

當我使用該更改重新啟動(或啟動)nginx 時,我收到以下錯誤:

[root@localhost ~]# systemctl restart nginx
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

[root@localhost ~]# systemctl status nginx.service
(...)
nginx: [emerg] open() "/usr/share/nginx/syslog:server=[10.1.2.3],facility=local7,tag=nginx,severity=info" failed (13: Permission denied)
(...)

就像服務不知道如何正確解析自己的配置文件一樣,就好像 IP 和選項是它試圖讀取的文件的一部分一樣。任何人都可以正常工作,我是否遺漏了一些明顯的東西?

你有舊的 nginx。

Logging to syslog is available since version 1.7.1. As part of our commercial subscription logging to syslog is available since version 1.5.3.

來自文件: http: //nginx.org/en/docs/syslog.html

引用自:https://serverfault.com/questions/793248