Here’s a quick, easy, 3 step method to log your custom events to the ULS while writing a SharePoint 2010 solution:
- Add a reference to Microsoft.Office.Server (located in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI on your SharePoint server)
- Add a using statement at the top of your code like so:
using Microsoft.Office.Server.Diagnostics;
- Add the following line wherever you want the message to appear in the ULS
PortalLog.LogString(<whatever you want to put in the ULS>)
See? That wasn’t so bad!