Looking for a simple class to add the ability to write to the Unified Logging Service (ULS) for your SharePoint 2010 project? Then the following should provide a good starting point for you.
Full source code for this example is available to download from here.
First things first, create a new class library project and add a class called Logger. Also add a couple of references to your project.
- Microsoft.SharePoint
- System.Web
Next, have your class inherit from the SharePoint class Microsoft.SharePoint.Administration.SPDiagnosticsServiceBase.
[System.Runtime.InteropServices.GuidAttribute("FBAF2022-DB19-4d2b-A029-948B747A4045")] public class Logger : SPDiagnosticsServiceBase { } |