Try If Not EventLog.SourceExists("TestLog") Then EventLog.CreateEventSource("TestLog", "TestLog") End If Dim oLog As New EventLog() oLog.Source = "TestLog" oLog.WriteEntry("TestLog", eventLogMessage, eventLogType) oLog = Nothing Catch Exp As Exception 'Do Nothing End Try
If Not EventLog.SourceExists("TestLog") Then
EventLog.CreateEventSource("TestLog", "TestLog")
End If
Dim oLog As New EventLog()
oLog.Source = "TestLog"
oLog.WriteEntry("TestLog", eventLogMessage, eventLogType)
oLog = Nothing
Catch Exp As Exception
'Do Nothing
End Try
我试了下面这段程序也不行:
if(!System.Diagnostics.EventLog.SourceExists("Service1"))
{
System.Diagnostics.EventLog.CreateEventSource("Service1","测试");
}
eventLog1.Source="Service1";
借宝地一块问问该怎么改
protected void LogEvent(string message,EventLogEntryType entryType)
{
if(!EventLog.SourceExists("mytest"))
{
EventLog.CreateEventSource("mytest","Application","mypc");
}
EventLog.WriteEntry("mytest",message,entryType);
}
好好研读一下这个KB
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B329291