Solved

windows event log from .net

Posted on 2013-01-04
2
497 Views
Last Modified: 2013-01-04
Is there a way to send a windows event from C#?
Something I can push via either a dos command or is there a library to send an event?

Thanks.
0
Comment
Question by:Evan Cutler
2 Comments
 
LVL 29

Accepted Solution

by:
Randy Downs earned 500 total points
ID: 38744175
This writes to an event log

http://support.microsoft.com/kb/307024

using System;
using System.Diagnostics;

namespace WriteToAnEventLog_csharp
{
	/// Summary description for Class1.
	class Class1
	{
		static void Main(string[] args)
		{
			string sSource;
			string sLog;
			string sEvent;

			sSource = "dotNET Sample App";
			sLog = "Application";
			sEvent = "Sample Event";

			if (!EventLog.SourceExists(sSource))
				EventLog.CreateEventSource(sSource,sLog);

			EventLog.WriteEntry(sSource,sEvent);
			EventLog.WriteEntry(sSource, sEvent,
				EventLogEntryType.Warning, 234);
		}
	}
}

Open in new window

0
 
LVL 9

Author Closing Comment

by:Evan Cutler
ID: 38744919
Thanks much...
0

Featured Post

Don't lose your head updating email signatures!

Do your end users still have the wrong email signature? Do email signature updates bore you or fill you with a sense of dread? You can make this a whole lot easier on yourself by trusting an Exclaimer email signature management solution. Over 50 million users do...so should you!

Join & Write a Comment

You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now