Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

EventLog::EnableRaisingEvents Property

 

Gets or sets a value indicating whether the EventLog receives EntryWritten event notifications.

Namespace:   System.Diagnostics
Assembly:  System (in System.dll)

public:
[BrowsableAttribute(false)]
property bool EnableRaisingEvents {
	bool get();
	void set(bool value);
}

Property Value

Type: System::Boolean

true if the EventLog receives notification when an entry is written to the log; otherwise, false.

Exception Condition
InvalidOperationException

The event log is on a remote computer.

The EnableRaisingEvents property determines whether the EventLog raises events when entries are written to the log. When the property is true, components that receive the EntryWritten event will receive notification any time an entry is written to the log that is specified in the Log property. If EnableRaisingEvents is false, no events are raised.

System_CAPS_noteNote

You can receive event notifications only when entries are written on the local computer. You cannot receive notifications for entries written on remote computers.

The following example handles an EntryWritten event.

#using <System.dll>

using namespace System;
using namespace System::Diagnostics;
using namespace System::Threading;
ref class MySample
{
public:
   static void MyOnEntryWritten( Object^ /*source*/, EntryWrittenEventArgs^ e )
   {
      Console::WriteLine( "Written: {0}", e->Entry->Message );
   }

};

int main()
{
   EventLog^ myNewLog = gcnew EventLog;
   myNewLog->Log = "MyCustomLog";
   myNewLog->EntryWritten += gcnew EntryWrittenEventHandler( MySample::MyOnEntryWritten );
   myNewLog->EnableRaisingEvents = true;
   Console::WriteLine( "Press \'q\' to quit." );

   // Wait for the EntryWrittenEvent or a quit command.
   while ( Console::Read() != 'q' )
   {

      // Wait.
   }
}

EventLogPermission

for writing the event log information on the computer. Associated enumeration: EventLogPermissionAccess::Write

.NET Framework
Available since 1.1
Return to top
Show:
© 2017 Microsoft