[Python] Logging settings overwritten by Python module

Discussão em 'Python' iniciado por Stack, Janeiro 30, 2025.

  1. Stack

    Stack Membro Participativo

    I'm a little bit confused about how best to approach setting up logging in my Python application.

    I'm using the IBPy module, which contains it's own logging here:

    import logging
    import os

    format = '%(asctime)s %(levelname)-9.9s %(message)s'

    datefmt = '%d-%b-%y %H:%M:%S'

    ##
    # Default log level. Set IBPY_LOGLEVEL environment variable to
    # change this default.
    level = int(os.environ.get('IBPY_LOGLEVEL', logging.DEBUG))


    def logger(name='ibpy', level=level, format=format,
    datefmt=datefmt):
    logging.basicConfig(level=level, format=format, datefmt=datefmt)
    return logging.getLogger(name)


    My application consists of a bunch of files that are imported into a Jupyter notebook. Final execution takes place inside the notebook.

    Currently, other modules are firing off on the 'DEBUG' level, and my notebook is full of warnings.

    What is the right approach to configure logging at the module level?

    Continue reading...

Compartilhe esta Página