EventLog in Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This lesson describes the EventLog control


This component enables an application to manipulate event logs, providing methods to create logs, write and read log messages, and clear logs.

In other words, it provides interaction with Windows event logs.

    ' check if it does not already exist
    If Not EventLog.SourceExists("ToolboxLessons") Then
        ' create the source
        EventLog.CreateEventSource("ToolboxLessons", "LessonsLog")
        Console.WriteLine("Creating Event Source...")
        ' the source is created so Exit the application to allow it to be registered. 
    End If

    ' instantiate an EventLog and assign the source
    Dim LessonsLog As New EventLog()
    LessonsLog.Source = "ToolboxLessons"

    ' write an informational entry to the event log.    
    LessonsLog.WriteEntry("Writing to the event log...")

Previous Lesson | Next Lesson

Share This

Home | About | Contact | Privacy Policy

Copyright visual-basic-tutorials.com 2018 - All Rights Reserved.