使用 django 进行扭曲日志记录
我的服务器已经投入生产,我在twisted 上运行django。 我有以下记录:
log.startLogging(sys.stdout)
...
reactor.listenTCP(DJANGO_PORT, server.Site(wsgi_root, logPath=os.path.join('./log', '.django.log')))
但是,我只在我的 .django.log.X 文件中看到这些:
127.0.0.1 - - [25/Nov/2010:16:48:22 +0000] "GET /statics/css/xxx.css HTTP/1.1" 200 1110 "http://www.xxx.com/" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12"
我知道注册会引发很多错误,但日志中没有关于异常和错误的信息扔了!
如何实际输出 WSGI 文件生成的错误?
注意:我认为这与我必须更改 log.startLogging(sys.stdout) 有关。但是,如果解决方案确实要改变这一点,我想知道如何输出到 sys.stdout 以及文件。
My server is out in production, and I am running django on top of twisted.
I have the following for logging:
log.startLogging(sys.stdout)
...
reactor.listenTCP(DJANGO_PORT, server.Site(wsgi_root, logPath=os.path.join('./log', '.django.log')))
However, I am only seeing these in my .django.log.X files:
127.0.0.1 - - [25/Nov/2010:16:48:22 +0000] "GET /statics/css/xxx.css HTTP/1.1" 200 1110 "http://www.xxx.com/" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12"
I know for a fact that registration is throwing a lot of errors, but then the log has NOTHING about the exceptions and errors being thrown!
How can I actually output errors generated by the WSGI file?
Note: I think it has something to do with the fact that I have to change log.startLogging(sys.stdout). However, if the solution indeed is to change that, I would like to know how I can output to BOTH sys.stdout as well the file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Django 不使用 Twisted 的日志记录 API。
twisted.python.log.startLogging
仅配置 Twisted 的日志系统。 Django 可能使用 stdliblogging
模块。因此,您必须对其进行配置,以便将 Django 日志输出写入有用的地方。您可以在 .django.log.X 文件中看到请求日志,因为这些日志是由 Twisted HTTP 服务器记录的,与任何 Django 日志无关。Django doesn't use Twisted's logging APIs.
twisted.python.log.startLogging
only configures Twisted's logging system. Django probably uses the stdliblogging
module. So you'll have to configure that in order to get Django log output written somewhere useful. You see the request logs in your .django.log.X files because those are logged by the Twisted HTTP server, independently of whatever Django logs.