有没有办法用nlog颜色特定单词?我的目标是ColoredConsole
。
假设我想着色 longdate red和 callite blue。最好的方法是什么?这似乎不起作用:
<target xsi:type="ColoredConsole"
name="debugConsole"
layout="${longdate} ${callsite} ${message}">
<highlight-word text="${longdate}" foregroundColor="Red" />
<highlight-word text="${callsite}" foregroundColor="Blue" />
</target>
如果您用一些炭包裹longdate
和callsite
,则可以使用正则。
,例如
<target xsi:type="ColoredConsole"
name="debugConsole"
layout="(${longdate}) [${callsite}] ${message}">
<highlight-word regex="([^)]+)" foregroundColor="Red" />
<highlight-word regex="[[^]]+]" foregroundColor="Blue" />
</target>