如何更改 dev_appserver 的日志记录级别
您知道如何更改 Google App Engine dev_appserver
的日志记录级别吗?
我想将其设置为 ERROR 删除消息,例如:
INFO 2011-10-18 17:43:00,806 dev_appserver_multiprocess.py:637]
Running application foo on port 8106: http://localhost:8106
INFO 2011-10-18 17:47:12,927 dev_appserver.py:4247]
"GET /images/sprite.png HTTP/1.1" 200 -
Do you know how to change the logging level of Google App Engine dev_appserver
?
I would like to set it to ERROR removing messages like:
INFO 2011-10-18 17:43:00,806 dev_appserver_multiprocess.py:637]
Running application foo on port 8106: http://localhost:8106
INFO 2011-10-18 17:47:12,927 dev_appserver.py:4247]
"GET /images/sprite.png HTTP/1.1" 200 -
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
有两个略有不同的参数可让您控制日志级别:
log_level
和dev_appserver_log_level
。日志级别 {调试、信息、警告、严重、错误}
dev_appserver.py --log_level=debug
日志级别,低于该级别的应用程序代码生成的日志消息将不会显示在控制台上(默认值:info)
dev_appserver_log_level< /strong> {调试、信息、警告、严重、错误}
dev_appserver.py --dev_appserver_log_level=debug
日志级别,低于该级别由开发服务器生成的日志消息将不会显示在控制台上(默认值:info)
There are two slightly different arguments which let you control the log level,
log_level
anddev_appserver_log_level
.log_level {debug,info,warning,critical,error}
dev_appserver.py --log_level=debug
The log level below which logging messages generated by application code will not be displayed on the console (default: info)
dev_appserver_log_level {debug,info,warning,critical,error}
dev_appserver.py --dev_appserver_log_level=debug
The log level below which logging messages generated by the development server will not be displayed on the console (default: info)
查看代码,没有办法从命令行修改日志级别。您的解决方案很好(至少直到下一次更新为止,正如您所说)。
如果需要,您可以通过 GREP 进行管道传输,例如:
不理想但功能齐全。
Looking at the code, there isn't a way to modify the log level from the command line. Your solution is fine (at least until the next update, as you said).
You could pipe it through a GREP if you want, eg.:
Not ideal but functional.
接受的答案对我不起作用,但对接受的答案的评论确实给出了修复。这是一个社区 wiki 答案,旨在帮助避免混淆。
dev_appserver.py --dev_appserver_log_level=debug
将日志输出设置为调试级别。The accepted answer does not work for me, but the comments to the accepted answer do give a fix. This is a community wiki answer to help avoid confusion.
dev_appserver.py --dev_appserver_log_level=debug
sets the log output to debug level.我直接修改了
dev_appserver_main.py
的源代码:在下一次更新中,我将丢失此更改,但这不是问题;我真的很想要这个,因为日志控制台往往会冻结程序中的大量导入(我在 OSX 上)。
I have directly modified the source of
dev_appserver_main.py
in:On the next update I will lose this change but it is not a problem; I really wanted this because log console tend to freeze on huge imports from program (I'm on OSX).
在 Google App Engine 启动器中,选择“编辑”->“应用程序设置”,然后将 --debug 添加到“额外命令行标志”中。
In the Google App Engine Launcher select Edit->Application Settings, and add --debug into Extra Command Line Flags.