I am trying to revise my logging library. Here is where I’m stuck. I use an enumeration, let’s call it ActionType, to identify my operations like UserLogin, PurchaseOrder… hundreds of them. And I use this type in my logger methods. But since I am seperating my logger library from my project specific code in the sake of loose coupling and base library can’t access ActionType defined in a project, how can I achieve this. To clarify it let me explain same case in java. Java allows enums to implement interfaces. So I could write:
In base logger library I could define;
public interface IActionType {}
and in one of my several projects
public enum ActionType implements IActionType {UserLogin, PurchaseOrder, .....}
So when I called my logger.log(ActionType.UserLogin, ....) base library would get the underlying action. This would all be suffice. Is there anyway around it to accomplish this in c#? By the way, I considered using IoC containers, but I want something more elegant.
Many thanks for any help…
Here is approach log4net uses for
Levelclass (yes, it is class, not enum):And interface
Usage: