You could inject a filter into each appender's filter chain that looks for the active logger name stored as a property in the repository. If the property is not found the filter returns FilterDecision.Neutral, else it returns FilterDecision.Accept if loggingEvent.LoggerName matches.
(I haven't tested the code) http://www.ronosaurus.com/log4net/ActiveLoggerFilterScope.cs.txt using (new ActiveLoggerFilterScope("MyLogger")) { runTest(); } There is no attempt to remove the filter from the appenders because it automatically deactivates when the scope is disposed. ----- Original Message ---- From: Ayende Rahien <[EMAIL PROTECTED]> To: Log4NET Dev <log4net-dev@logging.apache.org> Sent: Tuesday, February 27, 2007 1:09:23 PM Subject: Re: Configuring from code I am using the InMemoryAppender for that, and it is working great. I don't want to enable all the logging, just one specific logger, and only for a very short period of time. On 2/27/07, Ron Grabowski <[EMAIL PROTECTED]> wrote: Open up just one log file and inspect it or one log message and inspect that? Could you write an Appender that keeps the last N messages in memory then inspect those messages during testing? ----- Original Message ---- From: Ayende Rahien <[EMAIL PROTECTED]> To: log4net-dev@logging.apache.org Sent: Tuesday, February 27, 2007 11:19:15 AM Subject: Configuring from code I need to configure log4net from code, to verify that some of my code is output the correct log messages. The issue is that I basically wants to do something like: EnableLogsFor("MyLogger"); //run test StopLogging(); The real problem is that the amount of logs that are generates is fairly huge, and I want to be able to open just one, and close just one, without impacting anything else. Any ideas how I can do that?