Tag Archive for Logging

SPRequest ULS Entries

The SharePoint ULS logs always report objects not being explicitly disposed of, even for some of the SharePoint object model calls, although these are supposedly false positives.

Now, not all entries that are flagged will be issues, but initially there’s no apparent easy way of determining if the object is indeed causing a memory leak.

A sample log entry will look like:

An SPRequest object was reclaimed by the garbage collector instead of being explicitly freed. To avoid wasting system resources, dispose of this object or its parent (such as an SPSite or SPWeb) as soon as you are done using it. Allocation Id: {FDE3179D-E9C7-476B-9E60-ED68C55827ED} To determine where this object was allocated, set Microsoft.SharePoint.Administration.SPWebService.ContentService. CollectSPRequestAllocationCallStacks = true.

The last line of this entry indicates a way of getting more useful information to allow you to diagnose the problem and determine if it requires fixing.
Read more

Unified Logging Service Class

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
{
}

Read more

Follow

Get every new post delivered to your Inbox

Join other followers: