System.Diagnostics.EventLog
类来写入系统日志。以下是一个简单的示例代码:,,``csharp,using System;,using System.Diagnostics;,,class Program,{, static void Main(), {, string source = "MyApp";, string log = "Application";, string message = "This is a test log entry.";,, if (!EventLog.SourceExists(source)), {, EventLog.CreateEventSource(source, log);, },, EventLog.WriteEntry(source, message, EventLogEntryType.Information);, },},
``,,这段代码首先检查事件源是否存在,如果不存在则创建它,然后写入一条信息类型的日志条目。Powered By Z-BlogPHP 1.7.3
Copyright Your WebSite.Some Rights Reserved.