This is my quick-and-dirty logging configuration that works for both scripts and containerized applications.

from logging import StreamHandler, getLogger
from os import getenv

stderr_handler = StreamHandler()
log = getLogger(__name__)
log.setLevel(getenv('LOG_LEVEL', 'INFO'))
log.addHandler(stderr_handler)

This will provide console output when developing locally and will be picked up by the Docker/containerd logging driver when running in docker compose, Kubernetes, etc.