NLog:ColoredConsole 中的颜色特定词
NLog: color specific words in ColoredConsole
有没有办法用 NLog 给特定的单词上色?我的目标是 ColoredConsole
.
假设我想将 longdate 染成红色,将 callsite 染成蓝色。最好的方法是什么?这似乎不起作用:
<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>
有没有办法用 NLog 给特定的单词上色?我的目标是 ColoredConsole
.
假设我想将 longdate 染成红色,将 callsite 染成蓝色。最好的方法是什么?这似乎不起作用:
<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>