Disable logger from imported module in a custom module
Clash Royale CLAN TAG#URR8PPP
Disable logger from imported module in a custom module
I usually define my logger in main.py and then I use the same format in all my other custom modules and classes.
However, since I imported the discovery module within MyClass I get lots of logs that I don't want. How can I disable only the discovery logs while keeping all others?
I've tried
main.py
import logging
import MyClass
logging.basicConfig(level = logging.INFO, format = '%(asctime)s:%(levelname)s:%(module)s:%(message)s')
logger = logging.getLogger(__name__)
myc = MyClass.MyClass()
myc.do_something()
MyClass.py
import logging
from googleapiclient import discovery
class MyClass(object):
def __init__(self):
self.logger = logging.getLogger(__name__)
def do_something(self):
# code using discovery
I've tried adding this to MyClass after importing both logging and discovery but it didn't help:
logging.getLogger('discovery').setLevel(logging.WARNING)
These are the logs I'm trying to get rid of:
2018-08-10 16:11:11,702:INFO:discovery:URL being requested: GET
https://www.googleapis.com/discovery/v1/apis/drive/v3/rest 2018-08-10
16:11:11,800:INFO:discovery:URL being requested: GET
https://www.googleapis.com/drive/v3/teamdrives?alt=json
discovery
googleapiclient.discovery
Duh! Thanks, I added that and it worked.
– Victor
Aug 10 at 20:28
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Wrong logger -
discovery
is notgoogleapiclient.discovery
.– user2357112
Aug 10 at 20:27