To detect if the log4net repository has ever been configured you can
check the following property:

log4net.LogManager.GetRepository().Configured

Cheers,
Nicko


> -----Original Message-----
> From: Peter Drier [mailto:[EMAIL PROTECTED] 
> Sent: 08 February 2007 14:56
> To: Log4NET User
> Subject: Re: Calling Configure serveral time
> 
> Sergey,
> 
> I had a similar problem, or desire not to configure 
> repeatedly..  Solved it with this "helper":
> 
> ---------
> public sealed class log4netHelper
> {
>     private static readonly log4net.ILog log = 
> log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetC
> urrentMethod().DeclaringType);
> 
>     public static void Configure()
>     {
>         if (!log.IsFatalEnabled)
>         {
>             FileInfo fi = new FileInfo( 
> AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
>             log4net.Config.XmlConfigurator.Configure(fi);
> 
>             log.InfoFormat("Log4Net configured with file: 
> {0}", AppDomain.CurrentDomain.SetupInformation.ConfigurationFile );
>         }
>     }
> }
> -----------
> 
> I'm assuming Fatal level is never false if logging is 
> configured, and I know it is false if logging hasn't been 
> configured..  So I can call this from the start of any of our 
> services, and the first one actually runs the configure, the 
> other ones silently skip it.  
> 
> note - we do configuration per app domain (long story).. so 
> you'll probably want to change which configuration file this 
> points at..  
> 
> -Peter
> 
> 
> 
> On 2/8/07, Sergey <[EMAIL PROTECTED]> wrote:
> 
>       Hi,
>       
>       Thanks for the answer. Are your plugin class created 
> one time only? If there 
>       are several instances of your class created then
>       XmlConfigurator.ConfigureAndWatch method is called 
> several times. Does it
>       work? I wonder if log4net reloads its configuration every time
>       ConfigureAndWatch is called. Does this re-load impact 
> application performance? 
>       
>       Regards,
>       Sergey
>       
>       
>       
> 
> 
> 

Reply via email to