日志消息未显示在控制台上
Log message not displaying on console
下面是我正在尝试 运行 的代码。但是日志消息没有显示在控制台上。我在 pycharm 上 运行ning 代码 Python3.8
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.')
下面是我正在尝试 运行 的代码。但是日志消息没有显示在控制台上。我在 pycharm 上 运行ning 代码 Python3.8
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.')