下面是我尝试运行的代码。但是日志消息没有显示在控制台上。我正在使用Python3.8 在pycharm上运行代码
import sys
import logging
ch = logging.StreamHandler(sys.stdout)
ch.setLevel(logging.DEBUG)
my_format = logging.Formatter('%(message)s')
ch.setFormatter(my_format)
LOGGER = logger.getLogger('myLogger')
LOGGER.addHandler(ch)
LOGGER.info('This message should get displayed on the console.')
import sys
import logging
ch = logging.StreamHandler(sys.stdout)
ch.setLevel(logging.DEBUG)
my_format = logging.Formatter('%(message)s')
ch.setFormatter(my_format)
LOGGER = logging.getLogger()
LOGGER.addHandler(ch)
LOGGER.setLevel(logging.INFO) # Look at this.
LOGGER.info('This message should get displayed on the console.')