从开发者控制台读取 Google App Engine 上的应用程序日志 [英] Reading Application Logs on Google App Engine from Developer Console

查看:27
本文介绍了从开发者控制台读取 Google App Engine 上的应用程序日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

request_log 包含来自 main.py 的日志,但我如何登录到应用程序日志而不是 request_log?

解决方案

不需要设置logger选项,只需要导入logging模块并调用它的函数就足够了,就像在您引用的页面上的示例中:

导入日志导入 webapp2类 MainPage(webapp2.RequestHandler):定义获取(自我):logging.debug('这是一条调试信息')logging.info('这​​是一条信息消息')

您还应该注意,应用程序日志不能独立查看,它们总是附加到请求日志中,以响应生成它们的请求.来自您引用的文档:

<块引用>

每个请求日志都包含一个应用程序日志列表(

如果在展开请求日志后仍然看不到应用日志,我怀疑您尝试在 特定 记录器上设置选项 - 'options_log' 记录器- 可能是你的问题.如果您仍然想设置选项,请尝试为默认记录器(根记录器?)而不是指定一个.或者完全删除选项.

Reading and Writing Application Logs discusses the difference between Request logs vs application logs.

In main.py running on App Engine I import logging and grab a logger (since it's named, options_log, I'm not using root logger):

import logging

log = logging.getLogger('options_log')
log.setLevel(logging.INFO)
...

log.info('Hello Log!')

I can't find any information on where to view my application logs in the Developer Console. I see only request_log and activity.

The request_log contains logging from main.py, but how do I log to application log and not request_log?

解决方案

You don't need to set the logger options, just importing the logging module and invoking its functions should suffice, just like the in examples on the page you referenced:

import logging

import webapp2


class MainPage(webapp2.RequestHandler):
    def get(self):
        logging.debug('This is a debug message')
        logging.info('This is an info message')

You should also note that the application logs can not be seen independently, they are always attached to the request log for the request in response to which they were produced. From the doc you referenced:

Each request log contains a list of application logs (AppLog) associated with that request, returned in the RequestLog.app_logs property. Each app log contains the time the log was written, the log message, and the log level.

Note: A request log can only hold 1000 app logs. If you add more than 1000,
the older logs will not be retained.

You need to click on the left-most caret to expand the request log entry to display the respective app log(s):

If after expanding the request log you still don't see your app logs I suspect that your attempt to set options on a specific logger - the 'options_log' one - might be your problem. If you still want to set options, try doing it for the default logger (root logger?) instead of specifying one. Or drop the options altogether.

这篇关于从开发者控制台读取 Google App Engine 上的应用程序日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆