Is it possible to promote the log traces issued from a child logger under a configured root logger?

We have a few specific python modules which have most of their log traces of the form logging.debug. The owner of that source wishes the log traces to be debug, another team wishes them to be info. The root logger the second team uses sets logging.INFO as their application’s logging level since there are a lot of other source modules which would flood the app’s logs with debug traces if the root logger were set to that level.

Is there a way to remap log traces from a specific module to promote them from debug to info that can satisfy both clients of this code?


here’s my unsuccessful attempt at this, I effectively promote the log level of the child logger but the root logger still recognizes the log traces as debug and filters them out

# Test module: first.py
import logging
from second import symbol, log_func

root_logger = logging.getLogger()
logger = logging.getLogger(__name__)

def setup_logger() :
    root_logger.setLevel(logging.INFO)
    stream_handler = logging.StreamHandler()
    stream_handler.setLevel(logging.INFO)
    info_formatter = logging.Formatter( "[%(levelname)s]  %(pathname)s::%(funcName)s  %(message)s" )
    stream_handler.setFormatter(info_formatter)
    root_logger.addHandler(stream_handler)

    root_logger.info("Root Logging initialized")


if __name__ == "__main__":
    setup_logger()
    logger.info(symbol)

    second_logger = logging.getLogger("second")
    logger.info(f"imported module log level before: {second_logger.level}")
    second_logger.setLevel(logging.DEBUG)
    logger.info(f"imported module log level after: {second_logger.level}")

    log_func()

#==================================================================================
# Imported module: second.py
import logging

logger = logging.getLogger(__name__)
symbol = "second_mod"


def log_func():
    logger.info(f"Log traces coming from module '{__name__}'")
    logger.debug("this is debug level") # <--------- how to get this trace visible??
    logger.info("this is info level")

this code yields the following console output

$ python first.py 
[INFO]  first.py::setup_logger  Root Logging initialized
[INFO]  first.py::<module>  second_mod
[INFO]  first.py::<module>  imported module log level before: 0
[INFO]  first.py::<module>  imported module log level after: 10
[INFO]  second.py::log_func  Log traces coming from module 'second'
[INFO]  second.py::log_func  this is info level

I know the logging hierarchy bubbles all the log traces from down below up to the root logger, which filters from above it all. However is there a way to effectively remap the log traces that are statically authored in a given module over to something else?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật