using System; using System.Collections.Generic; using System.Diagnostics.Tracing; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LogStudy.EventLog.Next { /// /// 自定义 EventSource 示例 /// [EventSource(Name ="EventLogNext-CustomEventSource")] public sealed class CustomEventSource : EventSource { /// /// 私有化构造,以使用单例优化性能 /// private CustomEventSource() { } /// /// 静态方法,获取单实例 /// public static CustomEventSource Logger { get; } = new CustomEventSource(); /// /// 自定义属性 /// [Event(1, Level = EventLevel.Informational, Keywords = Keywords.Startup)] public void AppStarted(string message, int ss) { WriteEvent(1, message,ss); } [Event(2, Keywords = Keywords.Requests)] public void RequestStart(int requestId) { WriteEvent(2, requestId); } [Event(3, Keywords = Keywords.Requests)] public void RequestStop(int requestId) { WriteEvent(3, requestId); } /// /// 应用程序结果 /// [Event(4, Keywords = Keywords.Requests)] public void AppStopd(string message) { WriteEvent(4, message); } /// /// 自定义 关键字 /// public class Keywords { public const EventKeywords Startup = (EventKeywords)0x0001; public const EventKeywords Requests = (EventKeywords)0x0002; public const EventKeywords AppStopd = (EventKeywords)0x0004; } } }