25

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?

brainjam
  • 18,863
  • 8
  • 57
  • 82

4 Answers4

9

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

dinnouti
  • 1,707
  • 2
  • 15
  • 21
  • I have tried to do this, under launch settings. (extra command line flags) i put this in and update. It does not seem to keep the extra command line flag there it is always empty. – ADL Apr 11 '17 at 04:04
3

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.

lacton
  • 2,316
  • 2
  • 22
  • 24
  • According to http://stackoverflow.com/a/17350827/242848, it's `--log_level=debug` (with '=' sign). Could you clarify/doublecheck, and possible point to some documentation and I will change the accepted answer. – brainjam Oct 29 '16 at 20:16
  • Thanks for the feedback. Both `--log_level=debug` and `--log_level debug` work, because of the way the `argparse` python module is designed. I edited my answer accordingly. – lacton Oct 30 '16 at 12:44
  • Ok, this is now the accepted answer. Could you change your first sentence to be less confusing. E.g. 'accepted answer' -> 'previously accepted answer' – brainjam Oct 30 '16 at 18:53
  • I deleted the previously-accepted answer since it's wrong, so mentioning it at all in this answer isn't necessary :) – Wooble Oct 31 '16 at 14:42
  • Thank you for your feedback. I have removed all mentions of an accepted answer. – lacton Nov 01 '16 at 17:09
1

another alternative to setting the log_level flag:

logging.getLogger().handlers[0].setLevel(logging.DEBUG)
Scott Driscoll
  • 2,869
  • 2
  • 23
  • 22
1

On a Mac:

1) click Edit > Application Settings

2) then copy and paste the following line into the "Extra Flags:" field

--log_level=debug

3) click Update

your debug logs will now show up in the Log Console

JonnyRizla
  • 11
  • 2