It seems a very simple question, but I can't find any good example for me.
I want to filter a logger which has a specific name.
For example
import logging
logging.root.setLevel(logging.DEBUG)
logging.root.addHandler(logging.StreamHandler())
logging.root.addFilter(logging.Filter(name="a"))
a = logging.getLogger("a")
b = logging.getLogger("b")
a.info("aaaaa")
b.info("bbbbb")
I expected that root logger will filters message from b
because I understood that logging.Filter
only pass the name
or childs of the name
.
But as you expect it just passes all of the messages.
What is the point I misunderstand?
unless part
, so how do i do to use filter ? could you give me a simple example ? – Phosphorism