我使用Django与FastCGI + nginx。在这种情况下,日志(错误)存储在哪里?


当前回答

我在/usr/local/nginx/logs/*目录中找到了它。

其他回答

在nginx配置文件中设置访问日志的位置是一个很好的实践。使用acces_log /path/如下所示。

keyval $remote_addr:$http_user_agent $seen zone=clients;

server { listen 443 ssl;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers   HIGH:!aNULL:!MD5;

if ($seen = "") {
    set $seen  1;
    set $logme 1;
}
access_log  /tmp/sslparams.log sslparams if=$logme;
error_log  /pathtolog/error.log;
# ...
}

Linux服务器上的日志位置:

Apache – /var/log/httpd/

IIS – C:\inetpub\wwwroot\

Node.js – /var/log/nodejs/

nginx – /var/log/nginx/

Passenger – /var/app/support/logs/

Puma – /var/log/puma/

Python – /opt/python/log/

Tomcat – /var/log/tomcat8

我在/usr/local/nginx/logs/*目录中找到了它。

cd /var/log/nginx/
cat error.log

对于Mac OS用户,可以在终端中输入nginx -help。

nginx version: nginx/1.21.0
Usage: nginx [-?hvVtTq] [-s signal] [-p prefix]
             [-e filename] [-c filename] [-g directives]

Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -T            : test configuration, dump it and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /opt/homebrew/Cellar/nginx/1.21.0/)
  -e filename   : set error log file (default: /opt/homebrew/var/log/nginx/error.log)
  -c filename   : set configuration file (default: /opt/homebrew/etc/nginx/nginx.conf)
  -g directives : set global directives out of configuration file

然后,您可以为配置和日志文件找到一些默认路径,在这种情况下:

/opt/homebrew/log/nginx/error.log