Friday, May 18, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: Why is LogManager not inheritable?
Prev Next
You are not authorized to post a reply.

Author Messages
Richard Collette

08/03/2006 3:14 PM  
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
 
Nicko Cadell

08/03/2006 3:49 PM  

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

Richard Collette

08/03/2006 8:19 PM  
I was thinking generics might help in this case too.  But I don't think it will happen any time soon to keep backward compatibility.

 
You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > Why is LogManager not inheritable?



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement