Tuesday, 22 September 2015

What is Unified Logging Service ?

Unified Logging Service (ULS) writes the error messages or custom logging information in to Sharepoint's Trace Logs.

     Though Sharepoint 2007 shipped with Unified Loging Service, it was for internal purpose only and not supported to work with custom code where as Sharepoint 2010 supports to work with custom code. This logging information is stored on a file system in the 'c:\program files\common files\Microsoft shared\web server extensions\14\Logs'. The location were all these log files are stored is called as 'ULS logs' or Trace Logs. This path can always be changed accordingly from Central Admin, under diagnostic logging settings.
   
Using Sharepoint 2010, it is very easy to log information from custom code with the help of SPDiagnosticsService class.

Ex:   SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("My Category", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, ex.Message, ex.StackTrace);

We can acheive creating a custom logging service by inheriting from SPDiagnosticsServiceBase class.

No comments:

Post a Comment