在 structlog 中设置渲染器树
setting up trees of renderers in structlog
我将如何配置 structlog
,以便使用 KeyValueRenderer
而 所有 [=21] 将包括上述 info
在内的所有消息发送到 stdout
=] 日志记录也会使用 JSONRenderer
?
转到文件
注意:我只想使用structlog,没有标准库的东西
如果您使用的是标准库日志记录,那么仅使用配置应该相当简单。查看 http://www.structlog.org/en/stable/standard-library.html#rendering-using-structlog-based-formatters-within-logging 中的日志记录配置示例 – ISTM 它做的事情非常相似?
structlog
不会开箱即用,您需要自己编写所需的代码。 structlog
的构建方式使这一点变得简单明了,它应该在十几个 LoC 左右。
我将如何配置 structlog
,以便使用 KeyValueRenderer
而 所有 [=21] 将包括上述 info
在内的所有消息发送到 stdout
=] 日志记录也会使用 JSONRenderer
?
注意:我只想使用structlog,没有标准库的东西
如果您使用的是标准库日志记录,那么仅使用配置应该相当简单。查看 http://www.structlog.org/en/stable/standard-library.html#rendering-using-structlog-based-formatters-within-logging 中的日志记录配置示例 – ISTM 它做的事情非常相似?
structlog
不会开箱即用,您需要自己编写所需的代码。 structlog
的构建方式使这一点变得简单明了,它应该在十几个 LoC 左右。