在哪里可以找到 nginx、使用 FastCGI 和 Django 的错误日志?

发布于 2024-08-10 20:47:51 字数 128 浏览 10 评论 0原文

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

I'm using Django with FastCGI + nginx. Where are the logs (errors) stored in this case?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

梦回梦里 2024-08-17 20:47:51

错误存储在 nginx 日志文件中。您可以在 nginx 配置文件的根目录中指定它:

error_log  /var/log/nginx/nginx_error.log  warn;

在 Mac OS X 上使用 Homebrew ,默认情况下在以下位置找到日志文件:

/usr/local/var/log/nginx

Errors are stored in the nginx log file. You can specify it in the root of the nginx configuration file:

error_log  /var/log/nginx/nginx_error.log  warn;

On Mac OS X with Homebrew, the log file was found by default at the following location:

/usr/local/var/log/nginx
静赏你的温柔 2024-08-17 20:47:51

我正在寻找不同的解决方案。

默认情况下,在我的系统上设置任何配置之前的错误日志(x86 Arch Linux),被发现于:

/var/log/nginx/error.log

I was looking for a different solution.

Error logs, by default, before any configuration is set, on my system (x86 Arch Linux), was found in:

/var/log/nginx/error.log
虐人心 2024-08-17 20:47:51

在大多数情况下,您可以使用 lsof(打开文件列表)来查找打开的日志文件,而无需了解配置。

示例:

查找httpd的PID(同样的概念也适用于nginx和其他程序):

$ ps aux | grep httpd
...
root     17970  0.0  0.3 495964 64388 ?        Ssl  Oct29   3:45 /usr/sbin/httpd
...

然后使用lsof搜索打开的日志文件PID:

$ lsof -p 17970 | grep log
httpd   17970 root    2w   REG             253,15     2278      6723 /var/log/httpd/error_log
httpd   17970 root   12w   REG             253,15        0      1387 /var/log/httpd/access_log

如果 lsof 没有打印任何内容,即使您希望找到日志文件,也可以使用 sudo 发出相同的命令。

您可以阅读更多内容 此处

You can use lsof (list of open files) in most cases to find open log files without knowing the configuration.

Example:

Find the PID of httpd (the same concept applies for nginx and other programs):

$ ps aux | grep httpd
...
root     17970  0.0  0.3 495964 64388 ?        Ssl  Oct29   3:45 /usr/sbin/httpd
...

Then search for open log files using lsof with the PID:

$ lsof -p 17970 | grep log
httpd   17970 root    2w   REG             253,15     2278      6723 /var/log/httpd/error_log
httpd   17970 root   12w   REG             253,15        0      1387 /var/log/httpd/access_log

If lsof prints nothing, even though you expected the log files to be found, issue the same command using sudo.

You can read a little more here.

相对绾红妆 2024-08-17 20:47:51

运行此命令,检查错误日志:

tail -f /var/log/nginx/error.log

Run this command, to check error logs:

tail -f /var/log/nginx/error.log
薄荷→糖丶微凉 2024-08-17 20:47:51

我的 ngninx 日志位于此处:

/usr/local/var/log/nginx/*

您还可以检查您的 nginx.conf 以查看是否有任何指令转储到自定义日志。

运行 nginx -t 找到您的 nginx.conf

# in ngingx.conf
error_log  /usr/local/var/log/nginx/error.log;
error_log  /usr/local/var/log/nginx/error.log  notice;
error_log  /usr/local/var/log/nginx/error.log  info;

Nginx 通常设置在 /usr/local/etc/ 中。服务器也可以配置为将日志转储到 /var/log

如果您有 nginx 安装的备用位置并且其他所有方法都失败,您可以使用 find 命令来找到您选择的文件。

find /usr/ -path "*/nginx/*" -type f -name '*.log',其中 /usr/ 是您要开始搜索的文件夹从。

My ngninx logs are located here:

/usr/local/var/log/nginx/*

You can also check your nginx.conf to see if you have any directives dumping to custom log.

run nginx -t to locate your nginx.conf.

# in ngingx.conf
error_log  /usr/local/var/log/nginx/error.log;
error_log  /usr/local/var/log/nginx/error.log  notice;
error_log  /usr/local/var/log/nginx/error.log  info;

Nginx is usually set up in /usr/local or /etc/. The server could be configured to dump logs to /var/log as well.

If you have an alternate location for your nginx install and all else fails, you could use the find command to locate your file of choice.

find /usr/ -path "*/nginx/*" -type f -name '*.log', where /usr/ is the folder you wish to start searching from.

落花随流水 2024-08-17 20:47:51

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

Logs location on Linux servers:

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
枕梦 2024-08-17 20:47:51

对于 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

For Mac OS users, you can type nginx -help in your terminal.

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

Then, you could find some default path for configuration and log files, in this case:

/opt/homebrew/log/nginx/error.log
﹂绝世的画 2024-08-17 20:47:51

在终端中输入以下命令:

sudo cat /var/log/nginx/error.log

Type this command in the terminal:

sudo cat /var/log/nginx/error.log
梨涡少年 2024-08-17 20:47:51
cd /var/log/nginx/
cat error.log
cd /var/log/nginx/
cat error.log
独自←快乐 2024-08-17 20:47:51

在 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;
# ...
}

It is a good practice to set where the access log should be in nginx configuring file . Using acces_log /path/ Like this.

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;
# ...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文