log4net-dev

[Prev] Thread [Next]  |  [Prev] Date [Next]

RE: Memory leak due to LogImpl? Daniel Marohn Wed Apr 29 04:00:36 2009

Hi

> There is no matching -= for logger.Repository.ConfigurationChanged

There shouldnt be one, becourse once created the instance of the
logger will be stored by the repository until aplication ends. I you
use the same loggername you will get the same instance. I guess your
problem is that you do not use the logmanager or repositorie's
GetLogger member but create your instances by yourself (wich will
result in multiple instances of logger with the same name).

You need to implement the ILoggerFactory interface to create your
custom, subclassed logger. Then you configure the Hierarchy to use
your factory.
((log4net.Repository.Hierarchy.Hierarchy)log4net.LogManager.GetRepository).LoggerFactory
= new CustomFactory();

Now you can use the LogManager or the Repository to create loggers and
only one instance per name will be created.

hve phn!

Daniel