Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 9617 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > C# > Write to Event Log ...
Abhi2434

Write to Event Log

 Code Snippet posted by: Abhi2434 | Posted on: 10/2/2010 | Category: C# Codes | Views: 2560 | Status: [Member] [Microsoft_MVP] [MVP] | Points: 40 | Alert Moderator   
Ads

Writing to Eventlog is most simple. .NET provides a class which lets you write to EventLog very simply.

        public static bool WriteEventLog(string Message)

{
try
{
string sSource = "My Custom Application";
string sLog = "Application";
string sEvent = Message;

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

EventLog.WriteEntry(sSource, sEvent, EventLogEntryType.Error, 234);
return true;
}
catch { return false; }
}


You can call the method to put a Message on Application EvnetLogger of your system.

www.abhisheksur.com
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 6/20/2013 1:30:49 AM