I am trying to use NLog conditions to filter messages that are not generated at certain time
the following is my sample
<logger name="*" minlevel="Info" writeTo="InfoMail" >
<when condition="starts-with('${date:format=hh}', '01')" action="Ignore"/>
</logger>
However, Nlog seemed not able to pick up '${date:format=hh}' and I still receive email even the messages are generated at one o'clock. Is there any way to get around this?
The when conditions should be put inside a filters element as show in Conditions - Examples and specified in the NLog.xsd (the syntax on the When filter page is wrong)
So the correct usage is:
<logger name="*" minlevel="Info" writeTo="Console" >
<filters>
<when condition="starts-with('${date:format=hh}', '01')" action="Ignore"/>
</filters>
</logger>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With