How to make a certain piece optional in a NLog layout pattern?

余生长醉 提交于 2019-12-04 07:05:46
Richard R

I ran into a similar problem where I wanted to make to display some special formatting when a variable was not empty.

I took some inspiration from Most useful NLog configurations

${when:when=length('${jobName}') > 0:inner=${jobLayout}}

I'm not sure if this will get you 100% there, but it is a step in the right direction.

Did you try the whenEmpty layout renderer? https://github.com/nlog/NLog/wiki/WhenEmpty-Layout-Renderer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!