Python protocol suite level in basicConfig

Python protocol suite 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 expect?

+4
source share
1 answer

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

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

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

Source: https://habr.com/ru/post/1493343/


All Articles