1

I would like to create different logging rules for the Debug and for the Release situation. Better said, I would like to log TRACE level if I am in Debug mode.

<rules>
  <logger ... >
    <filters>
      <when condition="Condition" action="Enum"/>
    </filters>
  </logger>
</rules> 

NLog conditional config

This is how it is described, but I don't know how to config it for my desired function.

Franki1986
  • 1,320
  • 1
  • 15
  • 40
  • 6
    May I suggest another alternative: Just create two config files and have them copied to your output directories depending on build target. That's what we are doing and it works quite well. This also gives you the opportunity to add some appenders in debug, only. Or have different Message layouts... and I am sure you can find many other advantages. – Fildor Sep 13 '17 at 08:10
  • Good idea, so I could create a debug.config and a release config.. – Franki1986 Sep 13 '17 at 08:14
  • Right. And you can be sure that if you change debug.config, your release.config won't be affected in any way. – Fildor Sep 13 '17 at 08:16
  • 1
    For web you can use the web.config transform: https://msdn.microsoft.com/en-us/library/dd465326(v=vs.110).aspx – Stefan Sep 13 '17 at 08:20
  • @Stefan `XDT` transformation can be used for all of xml files not just for web and web.config – George Alexandria Sep 14 '17 at 20:48
  • We use SlowCheetah for all our config files. https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.SlowCheetah-XMLTransforms – JAZ Sep 22 '17 at 21:10

0 Answers0