1

我有一个使用谷歌应用引擎的网络应用程序。在 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..如果生成了任何应用引擎日志,则很难查看

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

4

2 回答 2

3

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

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

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

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

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

import logging
logging.getLogger().setLevel(logging.DEBUG)
于 2012-05-18T11:30:15.983 回答
2

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

于 2012-05-18T09:07:31.853 回答