On the google app engine, how do I change the defa

2019-03-30 01:59发布

Dev_appserver.py (the local development server for Python google app engine) spews tons of useless INFO messages. I would like to up this to WARN or ERROR. How can I do that?

I've tried the following, but it has no effect...

logger = logging.getLogger()
logger.setLevel(logging.WARN)

Any ideas?

3条回答
Ridiculous、
2楼-- · 2019-03-30 02:17

Currently, from the command line, you can only lower the logging level to DEBUG by the '-d' command line option.


If you're not afraid of editing the scripts, look for

DEFAULT_ARGS = {
  ...
  ARG_LOG_LEVEL: logging.INFO,

in C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver_main.py

查看更多
放我归山
3楼-- · 2019-03-30 02:19

Check if you have

      <!-- Configure java.util.logging -->
  <system-properties>
    <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
  </system-properties>

in your appengine-web.xml file, then go on to change .level = WARNING in your logging.properties file.

That's it!

查看更多
够拽才男人
4楼-- · 2019-03-30 02:24
logging.getLogger().handlers[0].setLevel(logging.DEBUG)

from Google App Engine/Python - Change logging formatting,

This is a bit of a hack because you have to directly access the handlers list stored in the root logger. The problem is GAE automatically uses logging before your code is ever run - this creates a default handler

查看更多
登录 后发表回答