什么是nLog版本的log4net的%属性

时间:2013-04-12 00:11:09

标签: nlog

使用log4net,我可以做到

log4net.ThreadContext.Properties["custom1"] = "value";
log4net.ThreadContext.Properties["custom2"] = "other value";

在配置文件中我可以放

"|%logger|%message|%newline%property"

它将呈现整个ThreadContext Dictionary。

我在nLog中找到了一个名为MDC的东西,但无论如何都找不到转储MDC字典包。

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:2)

在配置中定义目标时,您必须提供布局。例如:

<target xsi:type="Console" name="c" layout="${mdc:item=custom1}" />

但这只会呈现custom1值。无法在MDC中呈现所有属性。

相关问题