1

In my C# project, I have little bits of code here and there that look something like this:

#if DEV
DoStuff();
#else
DoOtherStuff();
#endif

These enable me to deploy two slightly-different versions of my application.

I use log4net to log information to a text file, and I'd like to change the logging level for different versions of my application. Normally, such a thing is controlled in the app.config file, like so:

<log4net>
  <logger name="MyNamespace.MyClass">
    <level value="DEBUG"/>
  </logger>
</log4net>

Is there a way to accomplish what I do in my C# source files in app.config? To illustrate, I'd like to essentially do this:

<log4net>
  <logger name="MyNamespace.MyClass">
#if DEV
    <level value="DEBUG"/>
#else
    <level value="INFO"/>
#endif
  </logger>
</log4net>

Is there a way to check for arbitrary compiler constants in app.config?

Eric Dand
  • 1,106
  • 13
  • 37

0 Answers0