Write an Event to the Windows Event Log - CSharp Operating System

CSharp examples for Operating System:Windows

Description

Write an Event to the Windows Event Log

Demo Code


using System;/*from   ww w .j  a  va  2 s  .  c  o m*/
using System.Diagnostics;

class MainClass
    {
        public static void Main ()
        {
            if (!EventLog.SourceExists("from book2s.com"))
            {
                EventLog.CreateEventSource("from book2s.com", "Application");
            }

            EventLog.WriteEntry(
                "from book2s.com",          // Registered event source
                "A simple test event.",        // Event entry message
                EventLogEntryType.Information, // Event type
                1,                             // Application specific ID
                0,                             // Application specific category
                new byte[] {10, 55, 200}       // Event data
            );
        }
    }

Result


Related Tutorials