I am currently in the process of designing a .net logging library that could potentially be used across different solutions in our organisation as a nuget package. However, I also want to make sure that we do semantic logging so that the logs are still structured.
Example -
CustomEventSource.Log.OrderProcessingFailed(order.OrderNumber, order.ItemCount);
Given that I am creating a shared service that is application agnostic, it shouldn't be tightly coupled to the application. Here is an example flow.
- Developer creates application and downloads logging package
- Developer creates EventsIds (e.g. OrderProcessingFailed), categories, keywords etc... specific to their application
- Developer creates instance of logging component passing details like machine name, event source name.
- Developer creates logs using logging instance passing details created in step 2 AND an array of name value parameters that are relevant (e.g OrderNumber: 1234, ItemCount: 3).
- Logging library writes the events in ETW.
- External listeners captures the events.
Has anyone seen a solution resembling above? My question is more on how to implement step 2 above. I don't want EventId to be free text but it should be something that the client is "forced" to implement similar to how an interface gives you an idea of how to implement what is required.
I know my question is a bit vague at this point so clarifications are welcome.