Say I have the following a.py which calls b.py
b.py
import logging
logging.info('11111 in b')
def do():
logging.info('2222222 in b')
a.py
import logging
import sys
import b
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
logging.info('11111111 in a')
b.do()
When I execute a.py, nothing gets logged to stdout, but when I comment out logging.info('11111 in b') from b.py as below:
b.py
import logging
# logging.info('11111 in b')
def do():
logging.info('2222222 in b')
I can see log output:
INFO:root:11111111 in a
INFO:root:2222222 in b
So obviously there is something to do with that commented out line, but I would have thought the basicConfig() would set something straight after importing b module but it's not.
Could someone please explain what's happening here?