You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System.Diagnostics.Tracing;
|
|
|
|
|
|
|
|
|
|
namespace LogStudy.EventLog.Next
|
|
|
|
|
{
|
|
|
|
|
internal class Program
|
|
|
|
|
{
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("======== 高级事件日志学习 ========");
|
|
|
|
|
|
|
|
|
|
//UseTest();
|
|
|
|
|
UseDefaultSource();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("按回车键,退出!");
|
|
|
|
|
//Console.ReadLine();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void UseTest()
|
|
|
|
|
{
|
|
|
|
|
EventSource defaultEventSource = new EventSource("Demo");
|
|
|
|
|
|
|
|
|
|
defaultEventSource.Write("xxxxx","xxxxxxxxxxxxxxxxxxxxxxxx");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void UseDefaultSource()
|
|
|
|
|
{
|
|
|
|
|
EventSourceSettings settings = EventSourceSettings.EtwSelfDescribingEventFormat | EventSourceSettings.ThrowOnEventWriteErrors;
|
|
|
|
|
EventSource defaultEventSource = new EventSource("Andy-DemoTest", settings, new string[] { "First", "Second" });
|
|
|
|
|
|
|
|
|
|
EventSourceOptions options = new EventSourceOptions()
|
|
|
|
|
{
|
|
|
|
|
Keywords= EventKeywords.All,
|
|
|
|
|
Level = EventLevel.Verbose,
|
|
|
|
|
Opcode = EventOpcode.Info,
|
|
|
|
|
Tags = EventTags.None,
|
|
|
|
|
ActivityOptions = EventActivityOptions.Recursive,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
defaultEventSource.Write("xxxxx", options, "000000000000000000000000000000000000000000000000");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|