查看 google 应用程序引擎 Python 在 CodeEnvy 中记录消息

viewing google app engine Python logging messages in CodeEnvy

我正在尝试将我的 GAE 开发转移到云端。到目前为止,Codeenvy 拥有最丰富的工具集,但我正在努力解决一个小问题。当我使用 python 日志库时,我不知道在哪里可以查看这些消息!

def post(self):
    self.response.write('Processing form data...')
    feedback = self.request.get('content')
    logging.info(feedback)

我以为它们会出现在控制台中 window 但是它们并没有在那里输出。考虑到 Codeenvy 对 GAE 的巨大支持,这似乎不受支持,这似乎很奇怪。

当您使用 logging 库时,消息应该开箱即用地显示在 Codenvy 的控制台中。

还要在 Google 开发者控制台中查看您的自定义日志,

您可能需要提供 logging.getLogger().setLevel(logging.DEBUG)

import logging
logging.getLogger().setLevel(logging.DEBUG)
...
...
def get(self):
    logging.info('Starting feedback...')
    self.response.write('Processing form data...')
    feedback = self.request.get('content')
    logging.info(feedback)

当我在 Codenvy 中尝试这样做时,我得到了以下响应

[STDOUT] INFO     2015-06-15 01:05:19,235 guestbook.py:62] Starting feedback...
[STDOUT] INFO     2015-06-15 01:05:19,236 guestbook.py:65] 
[STDOUT] INFO     2015-06-15 01:05:19,239 module.py:666] default: "GET /test HTTP/1.1" 200 23

到现在view the logs in the Google Developers Console看下面,

The Logs Viewer provides a web-based UI to navigate, display, and search your logs. With the Logs Viewer you can view and search logs from all your instances and apply filters to narrow in on a specific event, regardless of where it was generated.

To access the Logs Viewer:

  1. Open your project in the Developers Console.
  2. Click Monitoring > Logs.
  3. Ensure App Engine is selected in the dropdown menu.