The EventSource contains the following method.
[Event(1001,Level = EventLevel.Informational,Keywords = EventSourceTest.Keywords.BusinessLayer)]
public void MethodEnter(string tenant, string user, string methodInfo)
if (this.IsEnabled(EventLevel.Informational, EventSourceTest.Keywords.BusinessLayer))
this.WriteEvent(1001, tenant, user, methodInfo);
and the following Keywords:
public static class Keywords
public const EventKeywords BusinessLayer = (EventKeywords)1;
public const EventKeywords ServiceLayer = (EventKeywords)2;
The configuration of the out-of-process service contains only one sink with the following initial configuration:
<eventSource name="EventSourceTest" level="Informational" matchAnyKeyword="2"/>
Initially the the setting 'matchAnyKeyword' has the value "2". When executing 'EventSourceTest.MethodEnter', the 'IsEnabled' method returns 'false' (expected behaviour because the keywords don't match).
Now change the setting 'matchAnyKeyword' to "1". The 'IsEnabled' method returns 'true' (expected bahaviour behaviour because the keywords do match now).
Change the setting 'matchAnyKeyword' back to "2" again. The 'IsEnabled' method still returns 'true' (unexpected behaviour because the keywords don't match).
Why does 'IsEnabled' return true after the last change? It seems that the keyword '1' is not cleared for the eventsource after removing it from the sink settings. To clear it, the application, that contains the eventsource, must be restarted.