> 
> also, I changed my config filename to be "ItsMyAppConfigFile.config"

Your application's .config file must be called "Foo.exe.config" where
"Foo" is the name of your project. The .config file must be in the same
directory as your executable. So if your application is called "Foo"
then you would have the following files in the build output directory:

Foo.exe
Foo.exe.config

In this way each .NET exe can have a .config file. This is a feature of
the .NET runtime and noting to do with log4net.

The System.Diagnostics.Trace framework looks in the .config file for
information about trace listeners to create. If the log4netIntDebug.txt
file you have specified as the target for System.Diagnostics.Trace is
not getting created then your .config file is in the wrong place, or has
the wrong name, or you are running your application without enough
permissions to write to "C:\temp" (unlikely).

You can test that the System.Diagnostics.Trace framework is working by
calling System.Diagnostics.Trace.WriteLine(). This should write
something to the file you have specified in the
configuration/system.diagnostics/trace/listeners section of your
application's .config file.

When you have this working you can just call
log4net.Config.XmlConfigurator.Configure() with no arguments to have
log4net load its configuration from your application's .config file.


Nicko

> 
>  
> 
> And also changed my code to this....
> 
>  
> 
> string strPath = 
> System.IO.Path.GetDirectoryName(System.Reflection.Assembly.Get
> ExecutingAssembly().Location);
> 
>                   
> log4net.Config.XmlConfigurator.Configure(new 
> System.IO.FileInfo(strPath + "\\ItsMyAppConfigFile.config"));
> 
>  
> 
> What should I do next?
> 
>  
> 
>  
> 
> -----Original Message-----
> From: Ron Grabowski [mailto:[EMAIL PROTECTED]
> Sent: Friday, September 09, 2005 11:24 AM
> To: Log4NET User
> Subject: RE: Internal debugging
> 
>  
> 
> Is there anything inside of log4netInternalDebugging.txt?
> 
>  
> 
> Does your xml file look like this:
> 
>  
> 
> <?xml version="1.0" encoding="utf-8" ?>
> 
>  <configuration>
> 
>  ...
> 
>  </configuration>
> 
>  
> 
> Maybe the closing </xml> node is causing problems.
> 
>  
> 
> App.Config is a special filename in Visual Studio gets renamed to the
> 
> name of your executable when the project is compiled. If your proejct
> 
> was named Widget it would generate a Widget.exe as well as a
> 
> Widget.exe.config file. Are you sure your file is really app.config?
> 
> Since you're using the application's config file, you don't need to
> 
> specify the path to it:
> 
>  
> 
>  log4net.Config.XmlConfigurator.Configure();
> 
>  
> 
> --- Ramaa Davanagere <[EMAIL PROTECTED]> wrote:
> 
>  
> 
> > 
> 
> > Oh wow! I LOVE the idea of setting up the trace via the config file.
> 
> > This is
> 
> > very neat! I can enable it whenever I want. But why is it so hard to
> 
> > get
> 
> > things working though? I implemented the code changes you mentioned
> 
> > and its
> 
> > still not working. 
> 
> > 
> 
> > My new code looks like this.
> 
> > 
> 
> > public class myErrorHandler
> 
> >     {
> 
> >           
> 
> >           public ILog logger =
> 
> > LogManager.GetLogger(typeof(myErrorHandler));
> 
> > 
> 
> >           public myErrorHandler ()      
> 
> >           {     
> 
> >                 string strPath =
> 
> >
> 
> System.IO.Path.GetDirectoryName(System.Reflection.Assembly.Get
> ExecutingAssem
> 
> > bly().Location);
> 
> > 
> 
> >                 log4net.Config.XmlConfigurator.Configure(new
> 
> > System.IO.FileInfo(strPath + "\\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);
> 
> >           }
> 
> >     }
> 
> > 
> 
> > and my config file (app.config) looks like this.
> 
> > 
> 
> > 
> 
> > <xml>
> 
> >     <configuration>
> 
> >           <configSections>
> 
> >                 <section name="log4net"
> 
> > type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
> 
> >           </configSections>
> 
> >           <appSettings>
> 
> >                 <add key="log4net.Internal.Debug" value="true"/>
> 
> >           </appSettings>
> 
> >           <system.diagnostics>
> 
> >                 <trace autoflush="true">
> 
> >                       <listeners>
> 
> >                             <add name="textWriterTraceListener"
> 
> > type="System.Diagnostics.TextWriterTraceListener"
> 
> > initializeData="C:\\temp\\log4netInternalDebugging.txt"/>
> 
> >                       </listeners>
> 
> >                 </trace>
> 
> >           </system.diagnostics>
> 
> >           <log4net>
> 
> >                 <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="ALL"/>
> 
> >                       <appender-ref ref="FileAppender"/>
> 
> >                 </root>
> 
> >           </log4net>
> 
> >     </configuration>
> 
> > </xml>
> 
> 

Reply via email to