小编Kon*_*dov的帖子

Nlog / event-properties:如何提示 NLog 忽略/跳过最终日志条目中的空/空属性

基本上标题本身有点解释了我想要实现的目标,但更详细:

  1. 假设该布局具有类似于以下 XML 设置的内容:

    布局=“<日志级别='${level:lowerCase=True}'时间='${longdate:universalTime=true}'myCustomProperty1='${event-properties:item=myCustomProperty1}'myCustomProperty2='${event-属性:item=myCustomProperty2}'>${newline} ...."

  2. 现在,当 myCustomProperty1 设置为“blah1”但 myCustomProperty2 未添加到 eventInfo.Properties 集合时,结果条目如下所示:

    <日志级别='blah' 时间='blah' myCustomProperty1='blah1' myCustomProperty2=''> ...

  3. 问题是 - 可以做什么(最好在配置文件中)从最终呈现的结果中排除 myCustomProperty2 属性,以便输出如下所示:

    <日志级别='blah' 时间='blah' myCustomProperty1='blah1'> ...

这是问题 - 多个线程使用同一个记录器,因此我不能简单地在运行时更改目标的布局配置,因为它可能会对其余线程产生负面影响

预先感谢您的建议。-K

nlog

3
推荐指数
1
解决办法
2181
查看次数

标签 统计

nlog ×1