You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Chad Myers <ch...@chadmyers.com> on 2004/05/13 21:30:56 UTC

Dynamic reconfiguring

Hello all,

So I'm still frustrated by the lack of the ability to programmatically
confige log4net at runtime, so I've managed to get it partially working
by writing out config files and then calling the DOMConfigurator.

It seems to work only some of the time. It's not reliable which is very
disconcerting.

My code has written out the following config:
-----
<log4net>
  <root>
      <level value="DEBUG" />
	<appender-ref ref="I_LogManagerTestAppender" />
  </root>
  <appender name="I_LogManagerTestAppender" 	
	.... (appender params here ) ....
  </appender>
</log4net>
-----

Here's the code which I call after I've written the config file to disk:
-----
Hierarchy repository = 
	(Hierarchy) log4net.LogManager.GetLoggerRepository();
repository.Shutdown();
DOMConfigurator.ConfigureAndWatch( configFileInfo );
-----

Then, I call this:
ILog log = log4net.LogManager.GetLogger( typeof(LogManager) );

log.IsDebugEnabled still equals "False".

Why? The config file clearly has the root set to DEBUG, I reconfigure
and all loggers should have IsDebugEnabled == True, but they're not.

What am I missing?

I've tried it with and without the repository.Shutdown() and it has no
effect.

Any thoughts?
Thanks,
Chad Myers