how to disable log4net debug logging during runtime?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have a C# (VS2005) program running with log4net and everything is fine. Now there is a requirement to disable/enable the debug logging message. <br/> <br/> Could you please give me a code sample on how to disable the log.debug() during runtime? <br/> <br/> This is urgent. Please help.<br/> Thanks a <span id=main style=" <span id=search style=" zillion.
<pre lang="x-c# private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);[/code]
<pre lang=x-xml><?xml version="1.0" encoding="utf-8" ?>

<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender
<file value="c:\mylog.log" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="1024KB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>

<root>
<level value="ALL" />
<appender-ref ref="LogFileAppender" />
</root>
</log4net>

<!-- BugFix for serial close crash by uncatchable .Net internal exception -->
<!-- http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=140018 -->
<runtime>
<legacyUnhandledExceptionPolicy enabled="1"/>
</runtime>
<!-- Below system.net for HTTPWebRequest from GL config which seem non standard need this to work -->
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
</configuration>[/code]

View the full article
 
Back
Top