簡體   English   中英

python日志記錄不適用於使用Google App Engine的Web應用程序

[英]python logging does not work for web app using google app engine

我有一個使用Google App Engine的網絡應用程序。在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的directory..Still沒有日志創建.......我日志是在不知如何任何日志可以在谷歌應用程序引擎runs..Since它是在Linux下看,我沒有launcher with gui ..的launcher with gui如果生成任何應用程序日志,則很難查看

如果有人可以幫助我解決這個問題,那就太好了。

我在相同的環境(Ubuntu,python,gae)中遇到了與日志記錄類似的問題。

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

“沙箱確保應用程序只能執行不會干擾其他應用程序的性能和可伸縮性的操作。例如,一個應用程序無法將數據寫入本地文件系統或建立任意網絡連接。”

“開發服務器在本地計算機上運行您的應用程序以測試您的應用程序。該服務器模擬App Engine數據存儲區,服務和沙箱限制。”

我能夠使控制台日志記錄如下工作:

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

您是否閱讀過此https://developers.google.com/appengine/articles/logging ,據我了解,您不得聲明自己的日志文件

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM