【问题标题】:python logging does not work for web app using google app enginepython日志记录不适用于使用谷歌应用引擎的网络应用
【发布时间】:2012-05-25 20:24:45
【问题描述】:

我有一个使用谷歌应用引擎的网络应用程序。在 ubuntu 中,我使用

启动应用程序引擎
./dev_appserver.py /home/me/dev/mycode

在 mycode 文件夹中,我有 app.yml 和 web 应用程序的 python 文件。在 web 应用程序代码中,我使用日志记录来写入一些变量的值,例如

import logging
LOG_FILENAME = '/home/me/logs/mylog.txt'
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)


class Handler(webapp2.RequestHandler):
    ....

class Welcome(Handler):
    def get(self):
        if self.user:
            logging.debug('rendering welcome page for user')            
            self.render('welcome.html',username= self.user.name)
        else:
            logging.debug('redirect to signup')            
            self.redirect('/signup')
class MainPage(Handler):
        def get(self):
            self.redirect('/welcome')
app = webapp2.WSGIApplication([('/', MainPage),('/signup', Register),('/welcome', Welcome)], debug=True)

我已经为日志目录设置了chmod 777..仍然没有创建日志。我不知道当谷歌应用引擎运行时如何查看任何日志..因为它在 linux 中,我不知道'没有launcher with gui ..如果生成了应用引擎日志,则很难查看它们

如果有人能帮我解决这个问题,那就太好了。

【问题讨论】:

    标签: python google-app-engine logging


    【解决方案1】:

    我有相同的环境(Ubuntu、python、gae)并且遇到了类似的日志记录问题。

    您无法按此处所述登录到本地文件:https://developers.google.com/appengine/docs/python/overview

    “沙盒确保应用只能执行不干扰其他应用的性能和可扩展性的操作。例如,应用不能将数据写入本地文件系统或建立任意网络连接。”

    “开发服务器在您的本地计算机上运行您的应用程序以测试您的应用程序。服务器模拟 App Engine 数据存储区、服务和沙盒限制。”

    我能够让控制台日志记录工作如下:

    import logging
    logging.getLogger().setLevel(logging.DEBUG)
    

    【讨论】:

      【解决方案2】:

      您是否阅读过此https://developers.google.com/appengine/articles/logging,据我了解,您不得声明自己的日志文件

      【讨论】:

        猜你喜欢
        • 2014-03-01
        • 1970-01-01
        • 2011-05-18
        • 1970-01-01
        • 1970-01-01
        • 2016-08-27
        • 1970-01-01
        • 2011-01-24
        相关资源
        最近更新 更多