selective logger disable/enable

Gary Jefferson garyjefferson123 at
Fri Jan 19 08:08:18 CET 2007

Suppose I have 3 modules that belong to a project, 'A', 'A.a' and 'B',
and each module has its own logger, created with:

module1logger = logging.getLogger('project.A')


module2logger = logging.getLogger('project.A.a')


module3logger = logging.getLogger('project.B')

And I want to selectively enable/disable these, per module (for
example, I only want logging from A and A.a, or just from B, etc).  It
seems like logging.Filter is supposed to let me do this, but I can't
see how to apply it globally.  Is there really no other way that to add
a addFilter(filter) call to each of these loggers individually?

logging.basicConfig gets inherited by all loggers, but it doesn't seem
capable of giving a Filter to all loggers.  Is there any way to do this?

More information about the Python-list mailing list