ARTICLE AD BOX
I have a python project with this structure:
Project-Root/ |-- script.py |-- utils/ | |-- utils.py | |-- init.pyMy script.py looks like this - I import logging, setup an output file, import a function from utils, then run some code:
import logging from utils.utils import load_query # Setup logger logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) file_handler = logging.FileHandler('etl.log') logger.addHandler(file_handler) logger.info("Starting") load_query() logger.info("Finished")In utils.py, I setup logging by only calling getLogger, and then have the code for the function that includes a logger.info statement:
# Setup logger import logging logger = logging.getLogger(__name__) def load_query(): logger.info("Running function")I thought based on what I've read here and here this should propagate to the etl.log file setup in script.py, but my log file only shows the logs from script.py.
Why does this happen, and how can I propagate the logs up?
