When I compiled my application in release mode, I found that the Log4Net still logs debug information; any idea how to fix this?
This is my App.Config file:
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net"/>
</configSections>
<log4net>
<root>
<level value="DEBUG" />
<appender-ref ref="LogFileAppender" />
</root>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender" >
<param name="File" value="C:\Documents and Settings\test\Application Data\Log.txt" />
<param name="AppendToFile" value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%-5p%d{yyyy-MM-dd hh:mm:ss} - %m%n" />
</layout>
</appender>
</log4net>
Did I miss anything?
There's nothing in your App.Config file to tell log4net to do things differently in release or debug mode. If you want logging to be different between the two builds, you have to change your configuration file between the two builds.
Your best bet is probably to create one App.Config for Release, one for Debug, and then follow the advice in the StackOverflow question:
NOTE: The difference between your release and debug App.Config will be the following line in the debug version
<level value="DEBUG" />
versus the following line in the release version (or of course you could choose ERROR or FATAL if you want):
<level value="INFO" />
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