您的位置:首页 > 编程语言 > C#

C# 使用eventLog创建windows日志实例

2012-09-22 22:55 369 查看
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);//错误
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  windows c# string