是否可以配置 Django 开发服务器的输出以显示发出请求的客户端的 IP 地址?
问问题
690 次
2 回答
3
这在我们的新 Django 版本的“标准模块”列表中。对于 Django 1.2.1,在 django/core/servers/basehttp.py,第 614 行,更改:
msg = "[%s] %s\n" % (self.log_date_time_string(), format % args)
到
msg = "[%s] %s %s\n" % (self.log_date_time_string(),
self.client_address[0], format % args)
于 2010-09-19T23:55:41.670 回答
2
我向我建议的其他答案:
- 将 Gunicorn视为开发服务器:http ://gunicorn.org/ (orginNell)
- 考虑在 basehttp.py 上使用类继承来创建新的管理命令,避免弄乱核心代码(orginNell)
- 使用真实服务器 (Harro)
- 编写一些中间件以记录到文件 (Harro)
- 考虑用 django-devserver 替换内置服务器: http: //github.com/dcramer/django-devserver (mikeshantz)
- 我喜欢 django 的cherrypy:http: //www.cherrypy.org/ (John M)
- 切诺基也很好: http: //www.cherokee-project.com/ (John M)
于 2010-09-20T17:50:42.007 回答