Click here to Skip to main content
15,885,985 members
Articles / Programming Languages / C# 4.0

How To Create a Windows Event Log and Write your Custom Message as well

Rate me:
Please Sign up or sign in to vote.
4.92/5 (40 votes)
22 Aug 2009CPOL2 min read 200K   4.4K   79  
A simple class to create a Windows event log and write your custom message as well
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WELog;

namespace Test
{
    public partial class Test : Form
    {
        public Test()
        {
            InitializeComponent();
        }

        private void ButtonGo_Click(object sender, EventArgs e)
        {
            WELog.ClsEventLog ObjClsEventLog;
            ObjClsEventLog = new ClsEventLog();
            ObjClsEventLog.WriteToEventLog("myEventLog"
                                          , "ButtonGo. "
                                          , "I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.");
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions