如何在python的logging.conf中导入ssl模块?

2024-10-02 16:33:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用我的自定义loggingHandler,并希望在构造函数参数中向其传递ssl上下文,但不知道如何导入ssl模块。 这里有我的logging.conf的一部分

[handler_remoteHttpKafkaHandlerDebug]
class = xxx_some_service.http_logging.KafkaHTTPHandler
level = DEBUG
args = ('10.31.7.197:9898', '/log', 'SOME.KAFKA-TOPIC-LOGS-DEBUG', 1, True, ('root','god'), ssl.create_default_context(.....), 10, 60)

当然,我的日志记录程序失败了

NameError: name 'ssl' is not defined

有什么线索吗


Tags: 模块debughttpsslloggingconfservicesome
1条回答
网友
1楼 · 发布于 2024-10-02 16:33:38

嗯,伙计们,看起来很“特别”,但它很有效:

args = ('10.31.7.197:9898', '/log', 'SOME.KAFKA-TOPIC-LOGS', 1, True, ('root','god'), __import__('ssl').create_default_context(), 10, 60)

相关问题 更多 >