标签:
标准样例代码:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Diagnostics; using System.Diagnostics.Eventing; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string LogName = "Nieweiking_Log"; string SourceName = "Nieweiking的程序"; if (!EventLog.SourceExists(SourceName)) { var EventSourceData = new EventSourceCreationData(SourceName, LogName); EventLog.CreateEventSource(EventSourceData); } using (var log = new EventLog(LogName, ".", SourceName)) { log.WriteEntry("Message 1"); log.WriteEntry("Message 2", EventLogEntryType.Warning);; log.WriteEntry("Message 2", EventLogEntryType.Information, 33); } } } }
标签:
原文地址:http://www.cnblogs.com/qq458978/p/4647904.html