Propagating logging.logger from module to single log file
17:03 31 Dec 2025

I have a python project with this structure:

Project-Root/
|-- script.py
|-- utils/
|   |-- utils.py

My 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 this should propagate to the etl.log file setup in script.py, but my log file only shows the logs from script.py.

Can somebody provide a recipe to propagate the logs from my utilities up to this file?

python logging module