Thursday, June 27, 2013

Event logging mechanisms in SharePoint and other .net applications

While developing business applications, it’s important to implement a logging infrastructure to help other developers, administrators and System support engineers to trace the issue. Many different approaches are in practise today, although in this blog I am going to write different scenarios and different approaches we have adopted within different projects so far.
Scenario 1:
Application type - ASP.NET application
In one of asp.net web application for hospital management, on an event of processing a pdf document, results and logs were inserted into database. This required implementing a custom logging mechanism.
Scenario2:
Application type - Windows forms
Custom migration tool for migrating from documentum to SharePoint, we used custom text file based logging mechanism using log4net.dll. This is very nice custom tool available handling multithreading and highly configurable to define file names, new file creation rule and much more. Visit http://www.codeproject.com/Articles/140911/log4net-Tutorial for more info.
Scenario3:
Application type - SharePoint 2007 custom build intranet application
While developing a custom content management system where support team and infrastructure administration teams were two different silos, a hybrid logging approach was implemented. Logs which can be useful at L3 and L2 support tickets, were written to custom SharePoint list. Also other logs were written to ULS logs.
Note: Building logs based on SharePoint list, requires a good trashing mechanism to delete logs older than 2 months.
Scenario4:
Application type- SharePoint 2010 publishing site based intranet application
There are couple of options implementing logging within SharePoint applications. Selecting one of these options depends on many factors like timelines, clients preference, existing organizations approved practices, etc.
  1. SharePoint Guidance library: provides easy to reuse methods utility that can be easily employed in time crunched projects.
    http://msdn.microsoft.com/en-us/library/ff798385.aspx
  2. Building custom LoggingService implemented by inheriting SPDiagnosticsServiceBase. This provides better classification of ULS logs over logs created using method SPDiagnosticsService.Local.WriteTrace
    http://blog.mastykarz.nl/logging-uls-sharepoint-2010
I haven’t got any opportunity to explore any new and better mechanism available with SharePoint 2013 so far.