logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicko Cadell" <ni...@neoworks.com>
Subject RE: Why is LogManager not inheritable?
Date Thu, 03 Aug 2006 13:49:09 GMT
LogManager only contains static methods.
If you could extend it you would still need to implement all the methods
that return the ILog interface (use the new keyword). This doesn't help
when new methods are added to the LogManager as you wouldn't be hiding
it in your subclass so it would become unexpectedly available - your
users might use it, but the behaviour would not be as expected, i.e. it
would just be the same as calling the static method on the LogManager
class.

A much better solution is to use generics (.NET 2.0 and Mono 2.0 only),
to mean that you don't need to write a custom LogManager at all:

The calls to the LogManager would be something like:

ILog log = LogManager<ILog>.GetLogger("foo");

We can do something to keep backwards compatibility.

Then to define your own logger type you would just need to define a
factory class and probably configure that using an attribute on your
custom logger, then you could do:

CustomLog log = LogManager<CustomLog>.GetLogger("foo");

I haven't really work this through, but I think it should give a much
nicer solution than copying the whole of the LogManager and renaming the
return types.

Nicko

> -----Original Message-----
> From: Richard Collette [mailto:richard.collette@tritanka.com] 
> Sent: 03 August 2006 14:15
> To: log4net-user@logging.apache.org
> Subject: Why is LogManager not inheritable?
> 
> I implemented a custom LogManger to allow a couple additional 
> levels.  My concern going forward is that I will constantly 
> have to determine what new code is not present in my 
> LogManager vs. the standard Log4Net LogManager.
>  
> Insight?
>  
> Thanks,
> Rich
>  
> 

Mime
View raw message