I am new to both Google App Engine and Python. When things go wrong I'd like to see variable values and such, but print statements don't seem to be output anywhere. I would have expected them to appear in the same window where I started dev_appserver, but the only time I can see them is if a server error is imminent, then they appear in the output as I'd expect, right before the server error. Otherwise I don't see them.
I'm sure I'm missing something very fundamental... it seems everyone else can see their print statements just fine. I have tried using the logger functionality, but best I can tell it is intended for deployed apps. At any rate I can't see any output from those either. A simple example:
class PageHandler(BaseHandler):
def get(self):
// the page renders just fine, but no print statement to be found
print "rendering the page!"
self.render("page.html")
Am I just looking in the wrong spot for the print output? Do I need to be doing something to redirect output before printing? Very confused why the print statements work only when an error is about to occur.
print
outputs to standard output ( sys.stdout
) whose destination on a web app is always iffy. Rather, use the logging
module...:
import logging
...
logging.info('rendering the page')
and you'll be able to see all messages in the logs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.