【问题标题】:Python not logging to stdoutPython没有记录到标准输出
【发布时间】:2019-11-04 13:01:22
【问题描述】:

我有一个简单的 YAML 记录器配置:

simple-logger:
  version: 1
  formatters:
    simple:
      format: '%(asctime)s %(levelname)s %(module)s %(name)s.%(funcName)s %(message)s'
      datefmt: '%m/%d/%Y %I:%M:%S %p'
  handlers:
    console:
      class: logging.StreamHandler
      level: DEBUG
      formatter: simple
      stream: ext://sys.stdout

在初始化应用的工厂中,我使用dictConfig来初始化配置:

logging.config.dictConfig(config.get_attribute("simple-logger"))
logger = logging.getLogger(__name__)
logger.debug("Initializing...")

问题是,我在终端中没有得到任何输出。有什么问题?

【问题讨论】:

    标签: python python-3.x python-3.7 python-logging


    【解决方案1】:

    显然我必须明确告诉 root 使用控制台处理程序。

    root:
      level: DEBUG
      handlers: [console]
    

    解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-31
      • 2016-09-24
      • 2016-06-10
      • 1970-01-01
      • 1970-01-01
      • 2017-04-13
      • 1970-01-01
      • 2017-01-24
      相关资源
      最近更新 更多