Write an Event to the Windows Event Log - CSharp System

CSharp examples for System:Windows

Description

Write an Event to the Windows Event Log

Demo Code


using System;/*  ww w . j a v  a2 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