|
The code attached below is just not working. What is wrong? All I'm trying to do is, enable the internal debugging and write the message to log4netInternalDebugging.txt file. When I run this code, the file is getting created but no messages are getting logged. Please help
public class myErrorHandler {
public ILog logger = LogManager.GetLogger(typeof(myErrorHandler));
public myErrorHandler () { FileStream oFile = new FileStream("C:\\temp\\log4netInternalDebuggging.txt",FileMode.Create,FileAccess.Write); System.Diagnostics.Trace.Listeners.Add(new TextWriterTraceListener(oFile)); log4net.Util.LogLog.InternalDebugging = true; log4net.Config.DOMConfigurator.Configure(new System.IO.FileInfo("C:\\temp\\app.config")); }
public void WriteToLog_Info(string sMessage) { logger.Info(System.Reflection.MethodBase.GetCurrentMethod() + " " + sMessage); }
public void WriteToLog_Err(string sErrorMessage) { logger.Info(System.Reflection.MethodBase.GetCurrentMethod() + ": Exiting with Exception caught."); logger.Error(System.Reflection.MethodBase.GetCurrentMethod() + ": Error - " + sErrorMessage); } }
My App.cofig file looks like this.
<configuration> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/> </configSections> <appSettings/> <log4net debug="true"> <appender name="FileAppender" type="log4net.Appender.FileAppender"> <file value="C:\\temp\\mylog.txt"/> <appendToFile value="true"/> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%d %-5p %c %m%n"/> </layout> </appender> <root> <level value="DEBUG"/> <appender-ref ref="FileAppender"/> </root> </log4net> </configuration>
|
- Internal debugging Ramaa Davanagere
- Re: Internal debugging Farid LAOUFI
- Re: Internal debugging Ron Grabowski
- RE: Internal debugging Ramaa Davanagere
- RE: Internal debugging Ron Grabowski
- RE: Internal debugging Ramaa Davanagere
- RE: Internal debugging Ramaa Davanagere
- RE: Internal debugging Ron Grabowski
- RE: Internal debugging Ramaa Davanagere
- RE: Internal debugging Nicko Cadell
