[To be supplied.]
Initializes a new instance of the EventLog class.
[Visual Basic] Overloads Public Sub New()
[C#] public EventLog();
[C++] public: EventLog();
[JScript] public function EventLog();
[To be supplied.]
[Visual Basic] Overloads Public Sub New(String)
[C#] public EventLog(String);
[C++] public: EventLog(String*);
[JScript] public function EventLog(String);
[To be supplied.]
[Visual Basic] Overloads Public Sub New(String, String)
[C#] public EventLog(String, String);
[C++] public: EventLog(String*, String*);
[JScript] public function EventLog(String, String);
[To be supplied.]
[Visual Basic] Overloads Public Sub New(String, String, String)
[C#] public EventLog(String, String, String);
[C++] public: EventLog(String*, String*, String*);
[JScript] public function EventLog(String, String, String);
The following example connects to an event log, "myNewLog", on the local computer. If the source "myNewSource" does not already exist on the computer, it is created. Then, an entry is written to the Log.
Note that the way to create a new event log is through the static (in Visual Basic Shared) member CreateEventSource, which creates a Source and registers it to the Log at the time the log is created. Because this is a static (Shared) member of EventLog, it should be called on the class itself rather than on an instance of the class.
Import the System.Diagnostics namespace for this example.
Note This example shows how to use one of the overloaded version of the EventLog constructor. For other examples that may be available, see the individual overload topics.
[Visual Basic]
Private Sub ConnectToEventLog() 'Declare a new event log and event log entry. Dim evtLog As EventLog 'Instantiate a new event log. evtLog = New EventLog 'Otherwise, create a new source and log. If Not EventLog.SourceExists("MyNewSource") Then 'If MyNewLog does not exist, it will be created EventLog.CreateEventSource("MyNewSource", "MyNewLog") End If 'Connect the source to the event instance. evtLog.Source = "MyNewSource" 'Write an entry to the event log. evtLog.WriteEntry("My entry.") End Sub
EventLog Class | EventLog Members | System.Diagnostics Namespace