Confused about logger config from within Python (3)

andrew cooke andrew at acooke.org
Fri Dec 28 20:57:29 CET 2012


When I use a config file things seem to work (in other projects), but for my current code I hoped to configure logging from Python.

I distilled my problem down to the following test, which does not print anything.  Please can someone explain why?  I was expecting the module's logger to delegate to root, which has the DEBUG level set.

    from logging import DEBUG, root, getLogger
    from unittest import TestCase
    
    class LoggingTest(TestCase):

        def test_direct(self):
            root.setLevel(DEBUG)
            getLogger(__name__).debug("hello world")

Thanks,
Andrew



More information about the Python-list mailing list