Create an eventlog entry

Create an eventlog entry

For exception handling it is good practice to write errors to the eventlog.

EventLog.WriteEntry("SharePoint.Error", errorText, EventLogEntryType.Error);

Since SP1 for Windows Server 2003 "the normal user" is not allowed to write to the eventlog. James Kovacs wrote a great article about the problem.

(Remember to create your eventlog source, if you have your own!)

   1:  if(!EventLog.SourceExists("SharePoint.Error", ".")) {
   2:      EventLog.CreateEventSource("SharePoint.Error", "Application", ".");
   3:  }

Leave a Reply