Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google api client for python log level and debuglevel not working

While building a basic python app on AppEngine I found this page: https://developers.google.com/api-client-library/python/guide/logging

Which states you can do the following to set the log level:

import logging

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

However it doesn't seem to have any impact on the output which is always INFO for me. I set to logging.DEBUG and don't see any debug entries. I set to logging.WARNING and still see info entries. Never seems to change.

I also tried setting httplib2 to debuglevel 4:

import httplib2
httplib2.debuglevel = 4

Yet I don't see any HTTP headers in the log :/

Running python 2.7.10 in PyCharm.

Has anyone got these settings to work?

like image 648
Michael Avatar asked Nov 08 '22 08:11

Michael


1 Answers

I have faced a similar issue in python 3, fixed it by configuring a handler for the python logger:

logger.addHandler(logging.StreamHandler(sys.stdout))

I found this solution by wondering what handlers were initially present, and finding there were none:

print(logger.handlers)  # []
like image 88
Arnaud P Avatar answered Nov 14 '22 23:11

Arnaud P