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

前端 未结 4 987
余生分开走
余生分开走 2021-01-03 19:33

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 GoogleAppEng

相关标签:
4条回答
  • 2021-01-03 20:17

    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

    0 讨论(0)
  • 2021-01-03 20:22

    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

    0 讨论(0)
  • 2021-01-03 20:26

    another alternative to setting the log_level flag:

    logging.getLogger().handlers[0].setLevel(logging.DEBUG)
    
    0 讨论(0)
  • 2021-01-03 20:29

    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.

    0 讨论(0)
提交回复
热议问题