Skip to content Skip to sidebar Skip to footer

Python Logging Set Level In Basicconfig

python logging set level in basicConfig: import logging def show(level): logging.basicConfig(level=level) logging.info('info') logging.debug('debug') logging.warn(

Solution 1:

According to logging.basicConfig documentation, the second call to logging.basicConfig does not take effect.

This function does nothing if the root logger already has handlers configured for it.

def show(level):
    logger = logging.getLogger()
    logger.setLevel(level)
    logging.info('info')
    ....

Post a Comment for "Python Logging Set Level In Basicconfig"