Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

SPUsageSettings Class

Windows SharePoint Services 3

Encapsulates settings for usage analysis and logging in the Windows SharePoint Services deployment.

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

[GuidAttribute("61CA9E43-225E-4c7e-8FCB-1F7B1DF8B8A3")]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public class SPUsageSettings : SPPersistedObject

Use the UsageSettings property of the SPGlobalAdmin class to get an SPUsageSettings object directly from the UsageSettings property, but instead instantiate an SPUsageSettings object and assign the property to this object. The following code creates two separate SPUsageSettings objects and therefore does not update the settings.

SPWebService webService = SPContext.Current.Site.WebApplication.WebService;
webService.UsageSettings.SetProcessingInterval(1, 15, 1, 15);
webService.UsageSettings.Update();

The following code successfully modifies usage settings.

SPWebService webService = SPContext.Current.Site.WebApplication.WebService;

SPUsageSettings usageSettings  = webService.UsageSettings;
usageSettings.SetProcessingInterval(1, 15, 1, 15);
usageSettings.Update();

The following code example uses members of the SPUsageSettings class to modify usage analysis processing settings.

SPWebService webService = SPContext.Current.Site.WebApplication.WebService;
SPUsageSettings usageSettings  = webService.UsageSettings;

usageSettings.LoggingEnabled = true;
usageSettings.NumberLogFiles = 7;
usageSettings.LogFilesDirectory = "c:\\logs";
usageSettings.UsageProcessingEnabled = true;

usageSettings.SetProcessingInterval(1, 15, 1, 15);

usageSettings.Update();

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2015 Microsoft