0

In log4net I can add a custom property to the thread context like this:

ThreadContext.Properties["UserName"] = Thread.CurrentPrincipal.Identity.Name; 

I can then customize the format string to output this property in the log like this:

"%property{UserName}"

What would the equivalent of this be in the python logging framework?

4

1 回答 1

0

要使用 Python 将上下文信息添加到日志中,您可以使用 a LoggerAdapter、 aFilter或使用extra关键字参数将信息包含在日志调用中。有关更多详细信息,请参阅文档的此部分

于 2013-05-11T19:14:14.020 回答