Writing to the ULS in SharePoint 2010

Here’s a quick, easy, 3 step method to log your custom events to the ULS while writing a SharePoint 2010 solution:

  1. 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)
  2. Add a using statement at the top of your code like so:
    using Microsoft.Office.Server.Diagnostics;
  3. Add the following line wherever you want the message to appear in the ULS
    PortalLog.LogString()

See? That wasn’t so bad!

Eric

Eric Oszakiewski is a professional software developer based in Scottsdale, AZ with over 35 years of IT experience, and 19 years Native American Gaming experience. He is currently working as a Sr .Net/SharePoint Developer for General Motors, and also as a consultant.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube