Creazione registro eventi da VB.NET

Offrimi un Caffè

Per creare un registro eventi da Visual Basic.NET:

Private Function scrivi_registro_eventi(msg As String)
        Dim objEventLog As New EventLog()
        Dim AppName As String = "Test"
        Dim LogName As String = "Test"

        Try
            Dim MyEventReg As EventSourceCreationData = New EventSourceCreationData(AppName, LogName)
            EventLog.CreateEventSource(MyEventReg)

            objEventLog.Source = AppName

            'WriteEntry is overloaded; this is one
            'of 10 ways to call it
            objEventLog.WriteEntry("Messaggio da scrivere")

            MsgBox("Registro creato con successo", MsgBoxStyle.Information, "Creazione Registro")

        Catch Ex As Exception
            Return False
        End Try
    End Function