Hi Kevin,

 

I am not a log4net guru so hopefully one of the experienced guys will chime
in. In the mean time.

 

I have created a customer logger and use the following statement when adding
the logger to a class:

 

Private Shared mLog As IGSIEventLog =
GSIEventLogManager.GetLogger((Reflection.MethodBase.GetCurrentMethod().Decla
ringType))

 

The big difference is referencing "my" log manager and not the "default"
log4net log manager.

 

Also, I created my logger in the log4net.Ext.GSI namespace and so have the
following imports:

 

Imports log4net.Ext.GSI

 

Hope that helps!

 

Jon

 

 

From: Kevin Parkinson [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 17, 2007 5:04 PM
To: [email protected]
Subject: Building A Custom Logger

 

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)?

Reply via email to