62,025
社区成员
发帖
与我相关
我的任务
分享
public class ErrorLog
{
public static void WriteInErrorLog(string Sourcename, string message)
{
EventLog eventlog = null;
//确认日志是否存在
if (!(EventLog.SourceExists(Sourcename)))
{
EventLog.CreateEventSource(Sourcename, Sourcename + "log");
}
if (eventlog == null)
{
eventlog = new EventLog(Sourcename + "log");
eventlog.Source = Sourcename;
}
//写入日志
eventlog.WriteEntry(message, EventLogEntryType.Error);
}
}
if (!(EventLog.SourceExists(Sourcename)))