Reputation: 8477
I have a web app that uses google app engine .In ubuntu ,I start the app engine using
./dev_appserver.py /home/me/dev/mycode
In the mycode folder ,I have app.yml and the python files of the web app.In the web app code,I have used logging to write values of some variables like
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)
I have set chmod 777
for the logs directory..Still no logs are created there.I am at a loss as to how any log can be viewed when google app engine runs..Since it is in linux,I don't have a launcher with gui
..which makes it difficult to see the app engine logs if any are generated
If someone can help me solve this,it would be great.
Upvotes: 1
Views: 1381
Reputation: 116
I have the same environment (Ubuntu, python, gae) and ran into similar issues with logging.
You can't log to local file as stated here: https://developers.google.com/appengine/docs/python/overview
"The sandbox ensures that apps can only perform actions that do not interfere with the performance and scalability of other apps. For instance, an app cannot write data to the local file system or make arbitrary network connections."
"The development server runs your application on your local computer for testing your application. The server simulates the App Engine datastore, services and sandbox restrictions. "
I was able to getting console logging to work as follows:
import logging
logging.getLogger().setLevel(logging.DEBUG)
Upvotes: 3
Reputation: 7343
Did you read this https://developers.google.com/appengine/articles/logging as I understand you must not declare your own log file
Upvotes: 2