'CMRESHandler' 对象没有属性 '_timer'

0 python logging handler flask

当我的应用程序启动时,我得到 exeption '' CMRESHandler 'object has no attribute' _timer '"。当您启动 CMRESHandler 处理程序以将日志发送到 Elasticsearch 时会发生异常。

该问题仅发生在本地开发中,但是当我使用 Docker 运行项目时,不会发生错误。

    handler_es = CMRESHandler(
        hosts=[{"host": KIBANA_SERVER, "port": 443}],
        auth_type=CMRESHandler.AuthType.NO_AUTH,
        use_ssl=True,
        es_index_name="authenticator_server",
        es_additional_fields={"project": "myproject", "environment": ENVIRONMENT},
    )
    handler_es.setFormatter(formatter)
    logger.addHandler(handler_es)
Run Code Online (Sandbox Code Playgroud)

小智 5

我也遇到过这个问题,我认为是你的主机名有问题。

尝试执行:

sudo hostname localhost

并再次运行该项目。