Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting logging.debug() to work on Google App Engine/Python

Tags:

I'm just getting started on building a Python app for Google App Engine. In the localhost environment (on a Mac)

I'm trying to send debug info to the GoogleAppEngineLauncher Log Console via logging.debug(), but it isn't showing up. However, anything sent through, say, logging.info() or logging.error() does show up. I've tried a logging.basicConfig(level=logging.DEBUG) before the logging.debug(), but to no avail.

What am I missing?

like image 780
brainjam Avatar asked Jun 06 '10 03:06

brainjam


People also ask

How do I debug Google App Engine?

Debugging the application You can use the run configuration you previously created to run your application in debug mode as follows: Select Run > Debug. In the dialog, click Google App Engine Standard Local Server. After the project builds, you can set breakpoints to debug your app.

How do you log errors in Python?

Logging an exception in python with an error can be done in the logging. exception() method. This function logs a message with level ERROR on this logger. The arguments are interpreted as for debug().

How do I view Google API logs?

Viewing logsIn the Google Cloud console, go to the Logging page. When in the Logs Explorer, select and filter your resource type from the first drop-down list. From the All logs drop-down list, select compute.googleapis.com/activity_log to see Compute Engine activity logs.


2 Answers

In case someone is using the Windows Google Application Launcher. The argument for debug can be set under Edit > Application Settings

In the Extra Command Line Flags, add --log_level=debug

like image 156
dinnouti Avatar answered Sep 29 '22 13:09

dinnouti


The flag is --log_level debug.

Concretely, start your dev server with this command line:

dev_appserver.py --log_level debug . 

You can find this information by running dev_appserver.py --help. Here's the relevant quote from the command output:

--log_level {debug,info,warning,critical,error} the log level below which logging messages generated by application code will not be displayed on the console (default: info)

Using an equal sign (i.e., --log_level=debug) will also work, because the python script google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py relies on the argparse module, and the latter handles both spaces and the equal sign the same way, as stated in the official doc.

like image 27
lacton Avatar answered Sep 29 '22 12:09

lacton