Kevin Parkinson
2007-07-17 23:03:59 UTC
Has anyone had experience building a custom logger?
Here is what I am doing. I have created my own interface describing what the
kinds of things a logger needs to be able to log in my environment (let's
call it IInterface) like security audits, performance statistics, etc. This
interface extends ILog as well.
Thus: IInterface : ILog
Then, I have an implementation of IInterface and we'll call that
InterfaceImpl which also inherits from LogImpl (in order to satisfy the ILog
interface).
Like so: InterfaceImpl : LogImpl, IInterface
Now, when I go to put a logger in a class in which I want to perform
logging, by default I would usually put the line of code:
ILog _logger = LogManager.GetLogger(typeof(MyClass));
What I would like to do is to be able to say:
IInterface _logger = LogManager.GetLogger(typeof(MyClass));
...but this does not work (nor does anything else I have tried) because
GetLogger returns LogImpl which knows nothing of my IInterface.
Can anyone recommend anything that I can try without needing to modify the
LogManager (a sealed class)?
Here is what I am doing. I have created my own interface describing what the
kinds of things a logger needs to be able to log in my environment (let's
call it IInterface) like security audits, performance statistics, etc. This
interface extends ILog as well.
Thus: IInterface : ILog
Then, I have an implementation of IInterface and we'll call that
InterfaceImpl which also inherits from LogImpl (in order to satisfy the ILog
interface).
Like so: InterfaceImpl : LogImpl, IInterface
Now, when I go to put a logger in a class in which I want to perform
logging, by default I would usually put the line of code:
ILog _logger = LogManager.GetLogger(typeof(MyClass));
What I would like to do is to be able to say:
IInterface _logger = LogManager.GetLogger(typeof(MyClass));
...but this does not work (nor does anything else I have tried) because
GetLogger returns LogImpl which knows nothing of my IInterface.
Can anyone recommend anything that I can try without needing to modify the
LogManager (a sealed class)?