捕获谷歌应用程序引擎日志输出 [英] Capture google app engine logging output
问题描述
如何在管理控制台之外查看Google App Engine日志?我正在开发,因此使用 dev_appserver.py
我想在控制台中监视日志输出标准的Unix工具,例如less / grep / etc,但似乎没有选择从 dev_appserver.py
命令指导日志记录,并且无法打开新文件GAE(例如FileHandler),所以文件处理程序将无法工作,我认为使用套接字/ udp处理程序会有点矫枉过正(如果甚至可能的话)。
我希望还有其他选项可以查看日志。
感谢您的阅读。 解决方案
默认记录器将记录输出发送到 stderr
。使用shell的方法将 stderr
重定向到一个文件(在tcsh中,(dev_appserver.py> / dev / tty)>& your_logfile。 )
您也可以使用 logging
模块如果您发现它在本地运行( os.environ ['SERVER_SOFTWARE']。startswith('Dev')
),则在python中将记录器更改为直接发送到文件。 p>
How can one view the Google App Engine logs outside the Admin console?
I'm developing, so using dev_appserver.py
/the Admin Console and would like to see the logs as the records are emitted.
I'd like to monitor the logging output in a console with standard Unix tools e.g. less/grep/etc, but there doesn't seem to be an option to direct the logging from the dev_appserver.py
command, and I can't open a new file in GAE (e.g. a FileHandler), so file handlers won't work, and I think using a socket/udp handler would be a bit of overkill (if it's even possible).
I'm hopeful there are other options to view the log.
Thanks for reading.
The default logger sends logging output to stderr
. Use your shell's method of redirecting stderr
to a file (in tcsh, (dev_appserver.py > /dev/tty) >& your_logfile.txt
, your shell may vary.)
You can also use the logging
module in python to change the logger to send directly to a file if you detect it's running locally (os.environ['SERVER_SOFTWARE'].startswith('Dev')
)
这篇关于捕获谷歌应用程序引擎日志输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!