Compartir a través de


SPUsageSettings Class

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

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.Administration.SPAutoSerializingObject
    Microsoft.SharePoint.Administration.SPPersistedObject
      Microsoft.SharePoint.Administration.SPUsageSettings

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

Syntax

<GuidAttribute("61CA9E43-225E-4c7e-8FCB-1F7B1DF8B8A3")> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public Class SPUsageSettings _
    Inherits SPPersistedObject

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

Remarks

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.

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

The following code successfully modifies usage settings.

Dim webService As SPWebService = SPContext.Current.Site.WebApplication.WebService

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

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

Examples

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

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

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

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

usageSettings.Update()
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();

Thread Safety

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

See Also

Reference

SPUsageSettings Members

Microsoft.SharePoint.Administration Namespace