Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google App Engine: Logging in dev console?

Does logging work on the dev server? This code doesn't raise an exception, but I can't see where to view the logs in the devserver console. Perhaps I'm looking in the wrong place?

logging.error("error has occurred")
like image 685
Nick Heiner Avatar asked Jun 27 '10 18:06

Nick Heiner


People also ask

Which logs can be accessed from App Engine UI?

Logs in Google Cloud Platform for App Engine, and all other Google Cloud Platform resources can be viewed in Stackdriver Logging.


2 Answers

Make sure you create your logger. This should work.

Code

import logging

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

logging.error("uuu")
logging.info("ggg")

Launching from the CLI

$dev_appserver.py ~/workspace/helloworld/

The logs I got on the CLI...

ERROR    2012-11-26 03:02:25,467 helloworld.py:89] uuu
INFO     2012-11-26 03:02:25,467 helloworld.py:90] ggg

Note that this also works for me in Tornado.

like image 183
Alex Lauerman Avatar answered Sep 30 '22 13:09

Alex Lauerman


Yes, logging works on the dev server. When dev_appserver.py is run from the command-line, you should see output from logging calls such as the one you mentioned whenever they are called.

By default, only logging messages of INFO level and higher are printed.

Also, logging.error() does not raise an exception when called. It simply logs the string you pass at the "error" level - on the development server, this basically just means it will print "ERROR" as part of the logging message on the development server.

like image 24
David Underhill Avatar answered Sep 30 '22 11:09

David Underhill