Vinay Sajip wrote: > > The documentation for Logger - see > > http://docs.python.org/lib/node406.html > > - shows that there are addFilter() and removeFilter() methods on the > Logger class which you can use to add or remove filters from individual > Logger instances. From the above page (entitled "14.5.1 Logger > Objects"): > > addFilter(filt) > Adds the specified filter filt to this logger. > > removeFilter(filt) > Removes the specified filter filt from this logger. > > The parent section of Section 14.5.1, which is Section 14.5, was the > first search result when I just searched Google for "python logging".
Thanks for the reply Vinay. I had been reading those docs prior to posting, but addFilter/removeFilter only work on individual logger instances and handlers. I want to globally enable/disable multiple logger instances, based on their namespaces (see the example I provided). I cannot find a way to do this. I can certainly call addFilter on every instance of every logger throughout the source code, but this is more than inconvenient -- it breaks when new modules are added with their own loggers in their own namespaces (until fixed by manually adding addFilter() to those instances). e.g., suppose you have a source tree with a several components that do network access, and several components that do other things like saving state to disk, accessing the filesystem, etc. And suppose you find a bug that you think is in the networking code. It would be nice to be able to GLOBALLY enable just the loggers that belong in the networking namespace, and disable all others (similar to how Filters are supposed to work for individual loggers). And then to be able to do this with any component, by providing, for example, a command line switch or environment variable. Otherwise, the poor programmer is forced to go and edit every module in the source tree to selectively turn on/off their respecitve loggers. Or am I missing something really obvious about how this is done with the logging module? thanks, Gary -- http://mail.python.org/mailman/listinfo/python-list