I am developing some application at the moment which can run in two environments : development or production. I wish to have a different logging infrastructure for each.
The environment gets passed to my .exe at runtime. How can I enable/disable the respective appenders through code ? Is there something to tweak in the config below as well ?
I have other contents in this app.config file for application settings that give for each key a "prod" value and a "dev" value, based on this, so I do not want more than one config file.
<log4net>
<root>
<level value="debug" />
<appender-ref ref="Dev" />
<appender-ref ref="Prod" />
</root>
<appender name="Dev" type="log4net.Appender.FileAppender">
<file type="log4net.Util.PatternString" value="blabla 1" />
<layout type="log4net.Layout.PatternLayout">
<Header value="[Application Start] " />
<Footer value="[Application Exit] " />
<ConversionPattern value="%date (%property{ActiveStatus}) %-5level [%2thread] %-20.20logger{1} %message%newline" />
</layout>
</appender>
<appender name="Prod" type="log4net.Appender.FileAppender">
<file type="log4net.Util.PatternString" value="blabla 2" />
<layout type="log4net.Layout.PatternLayout">
<Header value="[Application Start] " />
<Footer value="[Application Exit] " />
<ConversionPattern value="%date (%property{ActiveStatus}) %-5level [%2thread] %-20.20logger{1} %message%newline" />
</layout>
</appender>
</log4net>