How to use interfaces in exception handling

I am working on an exception handling level for my application.

I read several articles about interfaces and generics. I have used inheritance before quite a lot, and I like it in this area.

I have a very short design that I am going to implement:

public interface IMyExceptionLogger
{
   public void LogException();

   // Helper methods for writing into files,db, xml
}

I'm a little confused about what I have to do next.

public class FooClass: IMyExceptionLogger
{

   // Fields
   // Constructors

}

Should I implement a method LogException()inside FooClass? If so, then I'm trying to figure out how best to use an interface instead of a specific class ...

I have many classes that will use this interface, but I do not want to write an implementation of this interface in each class.

, , - , OO...

, .

.

, net4log , , .

Edit:

. , .. DBExceptionLogger, CSVExceptionLogger, XMLExceptionLogger .. , .

+5
4

, IMyExceptionLogger. , , - . . , , :

class MyClass
{
    public MyClass(IMyExceptionLogger exceptionLogger)
    {
        ....
        exceptionLogger.LogException(e);
    }
}

IoC, Unity, .

+2

Logger , ( ).

- , - , Logger ( ctor ).

.

+1

, LogException() FooClass.

, (FooClass DBExceptionLogger ) IMyExceptionLogger. , .

+1

, , IExceptionLog. , , XmlLogger, SOAPLogger, . , , , IExceptionLog (). . , IoC-

+1

All Articles