The ILog is just an adapter. To change the configuration you need to get
its Logger property (the object that does the real work) and then you
need to cast it to the right type. The following methods should do the
job:


public static void RemoveAppender(log4net.ILog log, string appenderName)
{
 
((log4net.Repository.Hierarchy.Logger)log.Logger).RemoveAppender(appende
rName);
}

public static void RemoveAllAppendes(log4net.ILog log)
{
 
((log4net.Repository.Hierarchy.Logger)log.Logger).RemoveAllAppenders();
}

public static void AddAppender(log4net.ILog log,
log4net.Appender.IAppender appender)
{
 
((log4net.Repository.Hierarchy.Logger)log.Logger).AddAppender(appender);
}

public static void SetLevel(log4net.ILog log, log4net.spi.Level level)
{
  ((log4net.Repository.Hierarchy.Logger)log.Logger).Level = level;
}

Nicko 

> -----Original Message-----
> From: Andrew Elmhorst [mailto:[EMAIL PROTECTED] 
> Sent: 19 October 2004 15:19
> To: [email protected]
> Subject: Problems upgrading to version 1.2 from 1.1
> 
> I am trying to upgrade to log4net 1.2 beta from 1.1. One huge 
> thing that changed is that the Category class has been made 
> internal. I have some questions about how to port code 
> because of this.
> 
> I have changed my variables of type "Category" to "ILog" and 
> the creation of them to LogManger.GetLogger(). 
> 
> However, one of the things I need to do is switch the 
> Appender being used.
> What I used to call is Category.RemoveAllAppenders and 
> Category.AddAppender.
> Now, it looks like I need to cast my ILog instance to an 
> IAppenderAttachable interface, which is part of the spi 
> namespace, which is documented as being internal. Is this 
> what I should be doing? Can I safely assume that anything 
> that is an ILog is also going to be an IAppenderAttachable?
> 
> One last question . . . How do I set the Priority on my ILog instance?
> 
> Thanks in advance
> 
> Andrew Elmhorst
> 
> 
> 
> 

Reply via email to