I am using Enterprise Library SLAB for Logging but always since coupel of days I am getting error Use of undefined keyword value 0x1 for event ApplicationStarted. It is compiling fine but throwing runtime error just when we try to enable log event using following line
listener.EnableEvents(Logger.Log, EventLevel.LogAlways, Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Keywords.All)
;
Here is my eventsource
public static readonly Logger Log = new Logger();
[Event(100, Level = EventLevel.Informational, Keywords = Keywords.Application, Task = Tasks.ApplicationStarted, Opcode = Opcodes.Start, Version = 1)]
public void ApplicationStarted()
{
if (this.IsEnabled(EventLevel.Informational, Keywords.Application))
{
this.WriteEvent(100);
}
}
[Event(101, Level = EventLevel.Informational, Keywords = Keywords.Application, Task = Tasks.ApplicationClosed, Opcode = Opcodes.Closed, Version = 1)]
public void ApplicationClosed()
{
if (this.IsEnabled(EventLevel.Informational, Keywords.Application))
{
this.WriteEvent(101);
}
}
"Each keyword value is a 64-bit integer, which is treated as a bit array enabling you to define up to 64 different keywords."
"Although Keywords looks like an enumeration, it’s a static class with constants of type System.Diagnostics.Tracing.EventKeywords. But just as with flags, you need to make sure you assign powers of two as the value for each constant."
"If you decide to use keywords, you must define the keywords you will use in a nested class called Keywords"
The same story with the Tasks and Opcodes:
"You can use the Opcodes and Tasks parameters of the Event attribute to add additional information to the message that the event source logs. The Opcodes and Tasks are defined using nested classes of the same name in a similar way to how you define Keywords"
Differences are: "Opcodes and Tasks don’t need to be assigned values that are powers of two." And "If you choose to define custom opcodes, you should assign integer values of 11 or above."
You can read full article here:
https://msdn.microsoft.com/en-us/library/dn440729.aspx