简体   繁体   中英

Disable logger of specific python module in logging config file

I am using the below logging file and load it via fileConfig . I would like to configure the logging behavior of modules that are imported. For example, I want to disable (or set it to some higher log level) logging from urllib3 . How would I do that?

[loggers]
keys = root

[logger_root]
level = DEBUG
handlers = root

[handlers]
keys = root

[handler_root]
class = StreamHandler
level = DEBUG
formatter = json

[formatters]
keys = json

[formatter_json]
format = %(name)s%(message)s%(asctime)s%*(levelname)s%*(module)s
class = pythonjsonlogger.jsonlogger.JsonFormatter

Change your configuration to something like (these are just additions/changes to you what you posted):

[loggers]
keys = root,urllib3

[logger_urllib3]
level=CRITICAL
handlers=root
qualname=urllib3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM