python logging set level in basicConfig

前端 未结 1 1258
忘掉有多难
忘掉有多难 2021-01-18 13:19

python logging set level in basicConfig:

import logging

def show(level):
    logging.basicConfig(level=level)
    logging.info(\'info\')
    logging.debug(\         


        
1条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-18 13:56

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

    0 讨论(0)
提交回复
热议问题