The problem is that calling getLogger
without arguments returns the root logger so when you set the level to logging.DEBUG
you are also setting the level for other modules that use that logger.
You can solve this by simply not using the root logger. To do this just pass a name as argument, for example the name of your module:
logger = logging.getLogger('my_module_name')
# as before
this will create a new logger and thus it wont inadvertently change logging level for other modules.
Obviously you have to use logger.debug
instead of logging.debug
since the latter is a convenience function that calls the debug
method of the root logger.
This is mentioned in the Advanced Logging Tutorial. It also allows you to know which module triggered the log message in a simple way.