Feb 12, 2014 at 9:04 PM
Edited Feb 12, 2014 at 9:04 PM
Hello, I am working on a large application, consisting of a number of discrete services. Rather than implementing a single monolithic event source, I was hoping to implement one event source, per service, with a shared set of custom keywords between them.
Initially, I anticipated creating an abstract base class that inherited from EventSource. I had hoped to define the nested "Keywords" class within this base class. In this way, I expected that each of the subordinate event sources could then inherit
Regrettably, and perhaps understandably, while the keywords are accessible to the attribute initialization, it would appear that SLAB does not recognize them unless the nested "Keywords" class is declared immediately within the event source.
For my second attempt, I declared a keywords class immediately within the event source, but attempted to use inheritance (from a separate class) to inherit its class members (the EventKeywords constants).
This also did not work. Short of repeating the entire Keywords class declaration in the body of each of the event sources, is there anyway to share custom keywords?
I am hoping I have simply missed a mechanism that allows this sharing without code repetition.
However, between this and using methods to define events (instead of classes) my first impressions of SLAB is that its not very OO friendly.
Thank you for your assistance.
I don't think there is a way to share Keywords.
Semantic Logging is built on the .NET EventSource which is itself built on top of ETW. So, if it doesn't feel OO it's because it isn't entirely OO so it's a leaky abstraction.
One alternative is to use code generation either at build time or runtime to generate the required classes. I think that
does runtime code generation so that interfaces can be automatically implemented as EventSources. That might fit better with your desired approach.
Enterprise Library support engineer