Configuring child loggers

Viewed 8975

Every time I think I understand the logging module, gremlins come in and change the way it works. (Ok, I'll admit, that gremlin may be me changing my code.)

What am I doing wrong here?

> ipython
> import logging
> log = logging.Logger("base")
> log.addHandler(logging.StreamHandler())

> log.critical("Hi")
Hi

> log2 = log.getChild("ment")

> log2.critical("hi")
No handlers could be found for logger "base.ment"

I could have sworn that in the past, I was able to use child loggers without additional configuration...

2 Answers
Related