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