Steven,
We have code that does what you want. It was written several years ago
by someone who claimed to understand log4Net. I don't know if this is
the only way, the right way or just a way that happens to work.
We have our own LogManager class that has 4 static methods
public static MyLogger GetLogger
(System.Reflection.Assembly assembly, string name)
{
return
WrapLogger(log4net.Core.LoggerManager.GetLogger(assembly, name));
}
public static MyLogger GetLogger (Type logging_type)
{
return
GetLogger(System.Reflection.Assembly.GetCallingAssembly(),
logging_type.FullName);
}
public static MyLogger WrapLogger (log4net.Core.ILogger
logger)
{
return (MyLogger)my_wrappers.GetWrapper(logger);
}
private static log4net.Core.ILoggerWrapper
WrapperCreation (log4net.Core.ILogger logger)
{
return new MyLogger(logger);
}
and this
private static readonly log4net.Core.WrapperMap
my_wrappers =
new log4net.Core.WrapperMap(new
log4net.Core.WrapperCreationHandler(WrapperCreation));
MyLogger is a class that derives from log4net.Core.LogImpl
Instead of calling log4net.LogManager.GetLogger("myloggername") we call
our own LogManager class. You would need to add the GetLogger to match
your prototype of just a string name.
I will freely admit that I don't understand the whole wrapper part.
HTH
------------------------------------------------------------------------
----------
Roy Chastain
-----Original Message-----
From: steven higgan [mailto:[email protected]]
Sent: Wednesday, March 11, 2009 22:35
To: Log4NET Dev
Subject: use my own ILog implementation
What I want to do (and I am completely unsure about how to do it) is
that when I call :
static log4net.ILog log = log4net.LogManager.GetLogger("myloggername");
I want the instance of ILog that I get back to be my own implementation
of ILog
So how do I go about telling that how to create my instance ? can we
provide a factory or even a func?
thanks.