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.')
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)
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 - 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.')
But I find one I/O error.
I cannot give you specifics about PyScripter, but you need to set your IDE to pass the
-d
(or--debug
) flag to the dev_appserver.py. That enablesDEBUG
logs, otherwise you will see only messages of levelINFO
or higher.So you could try instead:
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.
For the non-file-based log, you would find the logs in the GAE admin console. (On your localhost, it is located at
See https://developers.google.com/appengine/articles/logging on how to use the logging module running on GAE.