string source = "mySource";
string logName = "myTestLog";
string logMessage = "warning infomation";
EventLog el = new EventLog(logName);
if (!EventLog.SourceExists(source))
{
EventLog.CreateEventSource(source, logName);
}
el.Source = source;
el.WriteEntry("normal infomation", EventLogEntryType.Information);//普通
el.WriteEntry(logMessage,EventLogEntryType.Warning);//警告
el.WriteEntry("error happened at " + DateTime.Now, EventLogEntryType.Error);//错误
C# 使用eventLog创建windows日志实例
最新推荐文章于 2022-05-15 16:43:35 发布