Prevent NLog inner text rendering when rendering output is output

I put the contents of my NLog email text message into a file and render it using the FileContents renderer. What I would like to do is hide some parts of the html output if the rendering of the layout creates an empty string

<div>Request ticket: ${httpContextItems:key=RequestTicket}</div>

I am not sure of the syntax for the condition / property . Here are a few attempts:

${httpContextItems:key=RequestTicket:when:length>0}
   <div>Request ticket: ${httpContextItems:key=RequestTicket}</div>
${??? How to enclose? }

And NLog doesn't like this enclosed stuff:

${when:when=length(${httpContextItems:key=RequestTicket})=0:inner=<div>Request ticket: ${httpContextItems:key=RequestTicket}</div>}
+4
source share
2 answers

I ran into a similar problem and made everything work like this:

${when:when=length('${httpContextItems:key=RequestTicket}') > 0:inner=&lt;div&gt;Request ticket ${httpContextItems:key=RequestTicket}&lt;/div&gt;}

, . NLog , , ( \, ${literal}, ASCII, ...).

+1

NLog :

${when:when=length(${httpContextItems:key=RequestTicket})=0:inner=<div>Request    ticket: ${httpContextItems:key=RequestTicket}</div>}

NLog - . NLog 4.2, - NLog. . GitHub

+1

Source: https://habr.com/ru/post/1523950/


All Articles