Why is logging ignoring the settings I’ve configured for suds logger?
In my Django app, I have logging set up in settings.py:
logging.basicConfig(
level = logging.DEBUG,
format = " %(levelname)s [%(asctime)s] %(filename)s: %(message)s",
datefmt='%d-%b %H:%M:%S',
)
I’m also using suds within this app, but don’t want to see the reams of messages from suds, so I added this:
SUDS_LOGGING_LEVEL = logging.CRITICAL
logging.getLogger('suds.client').setLevel(SUDS_LOGGING_LEVEL)
logging.getLogger('suds.transport').setLevel(SUDS_LOGGING_LEVEL)
logging.getLogger('suds.xsd.schema').setLevel(SUDS_LOGGING_LEVEL)
logging.getLogger('suds.wsdl').setLevel(SUDS_LOGGING_LEVEL)
logging.getLogger('suds.resolver').setLevel(SUDS_LOGGING_LEVEL)
logging.getLogger('suds.xsd.query').setLevel(SUDS_LOGGING_LEVEL)
logging.getLogger('suds.xsd.basic').setLevel(SUDS_LOGGING_LEVEL)
logging.getLogger('suds.binding.marshaller').setLevel(SUDS_LOGGING_LEVEL)
Yet I still see the suds DEBUG messages.
If I put a pdb breakpoint just before the suds call, I confirm that logging.getLogger('suds.client').level is 50 (logging.CRITICAL). I step to the suds line and I see all the logging.
If I temporarily change the level for the root logger, the logging is suppressed:
original_log_level = logging.getLogger().level
logging.getLogger().setLevel(logging.CRITICAL)
... do some suds stuff ...
logging.getLogger().setLevel(original_log_level)
This all suggests that suds is ignoring the suds logging levels.
Why?
Django 1.2.7, Python 2.7, suds 0.4 GA
Add
%(name)sto the format string. That will tell you exactly which suds loggers are still logging – perhaps you didn’t get all of them. (For example, code in suds/client.py logs to the logger named ‘suds.client’ but also logs to the logger named ‘suds.metrics’.)Also try setting the level of the ‘suds’ logger to CRITICAL and see if that cuts down the logging output.