我使用Django与FastCGI + nginx。在这种情况下,日志(错误)存储在哪里?
当前回答
在大多数情况下,可以使用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发出相同的命令。
你可以在这里读到更多。
其他回答
对于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
使用此命令查看错误日志:
tail -f /var/log/nginx/error.log
cd /var/log/nginx/
cat error.log
错误存储在nginx日志文件中。你可以在nginx配置文件的根目录中指定:
error_log /var/log/nginx/nginx_error.log warn;
在带Homebrew的Mac OS X上,默认情况下在以下位置找到日志文件:
/usr/local/var/log/nginx
我在/usr/local/nginx/logs/*目录中找到了它。
推荐文章
- 如何在django应用程序中显示favicon ?
- 如何在Django中设置时区
- Nginx提供下载。php文件,而不是执行它们
- django导入错误-没有core.management模块
- 如何从外部访问本地Django web服务器
- NGINX 499错误码的可能原因
- 在Django模型中存储电话号码的最佳方法是什么?
- 如何禁用django-rest-framework的管理风格的可浏览界面?
- 如何获取请求。Django-Rest-Framework序列化器中的用户?
- NGINX:从上游读取响应报头时超时(110:连接超时)
- 如何在Django模板中获得我的网站的域名?
- 在django Forms中定义css类
- 我应该在.gitignore文件中添加Django迁移文件吗?
- SQLAlchemy是否有与Django的get_or_create等价的函数?
- 如何选择一个记录和更新它,与一个单一的查询集在Django?