django - 通过 Nginx 和 Django 记录内部服务器错误
问题描述
我正在尝试记录通过我的 django 应用程序发生的内部服务器错误。
我已经通过 nginx 配置()为访问日志和错误日志设置了位置nginx.conf
:
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
...
设置后我只是重新加载了 nginx。每个访问都记录在access.log
文件中,没有任何问题,但内部服务器错误永远不会记录在error.log
文件中,但 nginx 确实可以访问它,因为它包含的唯一内容是[notice] 23802#0: signal process started
)。
我的 django 应用程序中有一个特定的 API,它返回 json(用于 Ajax)。不幸的是,该视图发生了一些内部错误(Ajax 仅记录状态代码和错误名称)。
我认为内部服务器错误不应该由 Nginx 处理,这是真的吗?如果是这样,我是否需要通过 Django 手动记录内部服务器错误?(process_exception()
?)。如果没有,是不是nginx配置有问题。
谢谢!
解决方案
推荐阅读
- android - 为什么我的Viewpager第二次打开后没有显示任何碎片,为什么不能使用childfragmentmanager?
- linux - 在 Ubuntu 20.04 上可以使用 netplan 配置多少个虚拟适配器?
- linux - 为什么 kprobe 在 Centos 7 内核 4.16.6 上不起作用?
- python - 在python中的两个数据框之间复制数据
- ruby-on-rails - 在大量数据的情况下,Rails 替换了简单的 ActiveRecord 关系
- docusignapi - DocuSign Envelope 草稿选项卡值在填充数据后最初未显示
- python - 如何监控正在运行的应用程序?
- python - 如何使用 ImageDataGenerator 将图像从 [0,255] 重新缩放到 [-1,1]?
- ios - 映射注释按钮以显示工作表... SwiftUI
- r - R 数据到列股票符号