EnjoySharePoint YouTube Channel

Write exception to Event Log in Asp.Net C#.Net

In this article, we will discuss how to write an exception to Event Log in Asp.Net.  You can check my previous posts on:
Event log will be accessible from Start -> Run -> eventvwr. To write the exception message in the Event log is now easy in .Net by use of the namespace System.Diagnostics;
Below is the code to write to event log:
using System.Diagnostics;
// Code
catch (System.Exception ex)
EventLog log = new EventLog();
log.Source = “Comes from .Net Application”;
log.WriteEntry(ex.Message, EventLogEntryType.Error);
// Clean up block.
Here in the above code the exception message will be written in the event log with source as “Comes from .Net Application”.
Now open the event viewer window ( Start -> Run -> eventvwr ) and Navigate to Windows Logs -> Application , You will able to see the error message.
Check out Best Alternative to InfoPath -> Try Now
You May Also like the Following SharePoint Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →