python logging set level in basicConfig

python

Solution

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')
    ....

Problem

python logging set level in basicConfig: ``` import logging def show(level): logging.basicConfig(level=level) logging.info('info') logging.debug('debug') logging.warn('warn') logging.error('error') logging.fatal('fatal') logging.warning('warning') logging.critical('critical') logging.exception('exception') show(logging.WARNING) show(logging.DEBUG) ``` The two results are the same, how to get what I expects?

Original source