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 Ron Grabowski <ro...@yahoo.com> on 2005/05/15 21:55:18 UTC

Wrapping LogManager to make ILog not rely on log4net.ILog

Nicko, 

Several months ago I found a post on the SourceForge forums that
described how to abstract the log4net.ILog interface into something
like MyProject.Logging.ILog to allow a project to change its logging
implementation. You provided sample code that looked something like
this:

public class LogManager
{
 private static readonly WrapperMap s_wrapperMap = new WrapperMap(
  new WrapperCreationHandler(WrapperCreationHandler));

 /* snip */

public static ILog GetLogger(string domain, string name)
{
 return WrapLogger(LoggerManager.GetLogger(domain, name));
}
public static ILog GetLogger(Assembly assembly, string name)
{
 return WrapLogger(LoggerManager.GetLogger(assembly, name));
}	
public static ILog GetLogger(Type type) 
{
 return GetLogger(Assembly.GetCallingAssembly(), type.FullName);
}
 
 /* snip */

There is much more code than that but does that give you an idea of
what I'm talking about? Do you a url for the post you made? I can't
seem to find it.

Is there a better (more effecient?) way to implement that in the new
log4net 1.2.9 beta? I found these classes:

http://tinyurl.com/cssnd
http://cvs.apache.org/viewcvs.cgi/logging-log4net/extensions/net/1.0/log4net.Ext.Trace/cs/src/

I didn't know if that was the correct class to check my code again. I
saw methods like:

 protected override void
ReloadLevels(log4net.Repository.ILoggerRepository repository)

that I don't have in my LogManager implementation and the /net/1.0/
directory structure also caused some confusion.

Thanks,
Ron