我想根据事件提供者名称获取事件提供者指南(例如:示例测试)
示例代码
[EventSource(Name = "Sample-Test")]
public sealed class EventSourceLogger : EventSource
这是我的提供者
internal class EventProviderVersionOne : EventProvider
{
internal EventProviderVersionOne(Guid id)
: base(id)
{ }
[StructLayout(LayoutKind.Explicit, Size = 16)]
private struct EventData
{
[FieldOffset(0)]
internal UInt64 DataPointer;
[FieldOffset(8)]
internal uint Size;
[FieldOffset(12)]
internal int Reserved;
}
}
我用于记录事件的记录器类
public class EventLogger
{
public static EventLogger Log = new EventLogger();
internal static EventProviderVersionOne MProvider = new EventProviderVersionOne(new Guid(ConfigurationSettings.AppSettings["EtwEventProviderGuid"]));
...
}
请根据 EventSourceName 建议获取 GUID 所需的代码。我已经注册了 Eventvwr。