Reputation: 5505
I plan to implement log4net later in my application but it is currently not possible. There will be a soft migration to newer technologies but it takes time. Therefore I have to use a proprietary log mechanism.
But when I implement new features I would like to be ready for the later migrations. So I would like to have a own class implementing the ILog interface so I can later switch to log4net without changes to the new features. This class would currently map to the proprietary log mechanism and later be obsolete.
My question is: As I do not have the log4net assembly in my project yet I have not an ILog interface. When I create my own ILog interface which would have exactly the same methods and signature, would it be compatible when I exchange it later?
Upvotes: 2
Views: 140
Reputation: 36
It would be compatible if you define interface not only with the same as it's defined in log4net assembly but also in the same namespace. When you would come to use log4net - just remove this own declaration of interface (and it's implementation)
Upvotes: 1
Reputation: 3616
I would define my own logger interface, similar to that of log4net but perhaps a bit more specialized. Then I would implement the interface as a proprietary logger. When time comes to move to log4net I would write a new implementation - a log4net wrapper.
Upvotes: 1
Reputation: 486
It won't be compatible. But it will be trivial to create a thin wrapper for log4net implementing your ILog
interface.
Upvotes: 2