class LogUtil : ILogUtility
{
object _classtype;
log4net.ILog log;
public LogUtil(object classtype)
{
_classtype = classtype;
log = log4net.LogManager.GetLogger(_classtype.GetType().FullName);
}
public void Log(LogType logtype, string message)
{
Console.WriteLine("logging coming from class {0} - message {1} " , _classtype.GetType().FullName, message);
}
}
From the client class code I call the above LogUtil class as follows:
public class TestCode
{
public void test()
{
LogUtil logutil = new LogUtil(this);
}
}
In the LogUtil constructor, I want to AVOID passing in object classtype.
I want to pass in the client class object that I can pass to the GetLogger Method. GetLogger method needs to know which class instantiated the LogUtil class.
The way I have it now, I can pass in integer variable class type and it would work. I want to avoid it.
How do I do that? How can I utilize generics method in this case?
Is this what you want?
You could then use it like this: