Export (0) Print
Expand All

EventLog.EnableRaisingEvents Property

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

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

property bool EnableRaisingEvents {
	bool get ();
	void set (bool value);
/** @property */
public boolean get_EnableRaisingEvents ()

/** @property */
public void set_EnableRaisingEvents (boolean value)

public function get EnableRaisingEvents () : boolean

public function set EnableRaisingEvents (value : boolean)

Property Value

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

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

The following example handles an EntryWritten event.

#using <System.dll>

using namespace System;
using namespace System::Diagnostics;
using namespace System::Threading;
ref class MySample
   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.

import System.*;
import System.Diagnostics.*;
import System.Threading.*;

class MySample
    public static void main(String[] args)
        EventLog myNewLog = new EventLog();
        myNewLog.add_EntryWritten(new EntryWrittenEventHandler(
        Console.WriteLine("Press \'q\' to quit.");

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

    private static void MyOnEntryWritten(Object source, EntryWrittenEventArgs e)
        Console.WriteLine("Written: " + e.get_Entry().get_Message());
    } //MyOnEntryWritten
} //MySample

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

© 2015 Microsoft