none
Meldungen einer Source werden in das falsche EventLog geschrieben RRS feed

  • Frage

  • Hallo,

    ich habe folgendes Problem: Beim Schreiben in das lokale Windows EventLog mittels der System.Diagnostics.EventLog Klasse werden Einträge für bestimmte Sourcen in das Application Log geschrieben anstatt in eine eigene LogDatei. Dieser Fehler tritt auf Windows Server 2003 und 2008 auf. Die Sourcen sind in der Registry dem richtigen Log zugeordnet.

    Die folgende Beispielanwendung zeigt das Problem.

    Option Explicit On
    Option Strict On
    
    Imports System
    Imports System.Diagnostics
    Imports System.Threading
    
    Class Module1
        Public Shared Sub Main()
            Dim log As String = "MyLog"
    
            ' This one is being written into the Application log
            Dim InCorrectSource As String = "ASP._layouts_services_controls_defaultreportingjobs_ascx BindOnlineReportingJobs ICFR2009"
            CreateEventSource(InCorrectSource, log)
            WriteEntry(InCorrectSource, "I should be in log " + log)
    
            ' This one is being written into the MyLog log
            InCorrectSource = "ASP._layouts_services_controls_defaultreportingjobs_ascx BindOnlineReportingJobsa"
            CreateEventSource(InCorrectSource, log)
            WriteEntry(InCorrectSource, "I should be in log " + log)
    
            ' This one is being written into the MyLog log
            Dim CorrectSource As String = "ASP._layouts_services_controls_defaultreportingjobs_ascx BindOnlineReportingJobs"
            CreateEventSource(CorrectSource, log)
            WriteEntry(CorrectSource, "I'm in log " + log)
    
            CorrectSource = "ASP._layouts_services_controls_defaultreportingjobs_ascx BindOnlineReportingJobs ICFR"
            CreateEventSource(CorrectSource, log)
            WriteEntry(CorrectSource, "I'm in log " + log)
        End Sub 'Main 
    
        Private Shared Sub CreateEventSource(ByVal Source As String, ByVal LogName As String)
            If Not EventLog.SourceExists(Source) Then
                EventLog.CreateEventSource(Source, LogName)
                Console.WriteLine("CreatingEventSource " + Source + " in Log " + LogName)
            End If
        End Sub
    
        Private Shared Sub WriteEntry(ByVal Source As String, ByVal Message As String)
            Dim myLog As New EventLog()
            myLog.Source = Source
    
            Dim logName As String = myLog.LogDisplayName
            Console.WriteLine("Source: " + Source)
            Console.WriteLine("LogDisplayName: " + logName)
            Console.WriteLine("Message: " + Message)
    
            ' Write an informational entry to the event log.    
            myLog.WriteEntry(Message)
        End Sub
    
    End Class 'MySample
    In der Methode WriteEntry wird immer das richtige Log gefunden, dennoch werden die ersten beiden Log Einträge in das Application Log geschrieben.
    Unter Windows 2003 erscheint bei den fehlerhaften Logeinträgen zusätzlich folgende Meldung:

    The description for Event ID ( 0 ) in Source ( ASP._layouts_services_controls_defaultreportingjobs_ascx BindOnlineReportingJobs ICFR2009 ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: I should be in log MyLog.


    Kann mir jemand erklären, wieso die ersten beiden Einträge im Application Log landen anstatt in MyLog?
    Dienstag, 21. April 2009 15:46

Antworten

Alle Antworten