如何查看GAE下的日志记录模块输出模块? [英] How to see logging module output module under GAE?

查看:136
本文介绍了如何查看GAE下的日志记录模块输出模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调试

I'm trying to debug this code. With this goal, I'm trying to use logging following this tutorial. With this goal, I insert this code in my script:

import logging

logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')

logging.debug('This is a log message.')

然后,在我想要获取消息记录的部分中,我以这种方式插入了行:logging.debug ('This is a log message.'):

And, in the section where I wanted to get the message logging, I inserted the line: logging.debug ('This is a log message.') this way:

def fcount(self,f,cat):
    res = db.GqlQuery("SELECT * FROM fc WHERE feature =:feature AND category =:category", feature = f, category = cat).get()
    logging.debug('This is a log message.')
#    res=self.con.execute(
#      'select count from fc where feature="%s" and category="%s"'
#      %(f,cat)).fetchone()
    if res is None: return 0
    else:
        res = fc.count
        return float(res)

事实证明,我的应用程序是GAE应用程序.而且我看不到日志消息,该消息未出现在浏览器或PyScripter IDE中.在哪里可以看到带有日志消息的屏幕?

It turns out that my application is an GAE application. And I cannot see the logging message, which doesn't appear in the browser or in PyScripter IDE. Where should I see the screen with the logging message?

PS-我尝试使用此代码将日志消息交替写入文件:

PS - I tried use this code to alternately write logging messages to a file:

import logging
logging.basicConfig(filename='log_filename.txt', level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
logging.debug('This is a log message.') 

但是我发现一个I/O错误.

But I find one I/O error.

推荐答案

您是要在Google App Engine上运行记录器还是在本地计算机上不运行记录器?如果它不能在GAE上运行,那是因为您已将记录器设置为写入文件,而GAE并没有真正允许您访问文件系统.

Are you trying to run the logger on the Google App Engine or is it not working on your local machine? If it's not working on GAE, it's because you have setup the logger to write to a file, and GAE does not really let you access the file system.

对于非基于文件的日志,您可以在GAE管理控制台中找到日志. (在您的本地主机上,它位于

For the non-file-based log, you would find the logs in the GAE admin console. (On your localhost, it is located at

http://localhost:8080/_ah/admin

请参见 https://developers.google.com/appengine/articles/logging 有关如何使用GAE上运行的日志记录模块的信息.

See https://developers.google.com/appengine/articles/logging on how to use the logging module running on GAE.

这篇关于如何查看GAE下的日志记录模块输出模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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