Skip to content

SPLogLevel

dscbot edited this page Mar 17, 2023 · 10 revisions

SPLogLevel

Parameters

Parameter Attribute DataType Description Allowed Values
Name Key String Friendly Name used to reference this collection of log level settings
SPLogLevelSetting Required MSFT_SPLogLevelItem[] Collection of SPLogLevelItems to set

MSFT_SPLogLevelItem

Parameters

Parameter Attribute DataType Description Allowed Values
Area Key String Log Item Area
Name Key String Log Item Name
TraceLevel Write String Minimum severity to capture in the trace logs None, Unexpected, Monitorable, High, Medium, Verbose, VerboseEx, Default
EventLevel Write String Minimum severity to capture in the event logs None, ErrorCritical, Error, Warning, Information, Verbose, Default

Description

Type: Distributed Requires CredSSP: No

This resource is used to change the minimum severity of events captured in the trace logs (ULS logs) and the Windows event logs. Settings can be changed globally for all areas and categories (using the '*' character as the wildcard), for all categories within an area, and for specific categories within an area. Settings can be changed to desired valid values, or set to the default by using the keyword 'Default' as the trace level and event level. You must specify a unique name for each instance of this resource in a configuration.

Examples

Example 1

This example sets an Area / Category item to a custom value.

Configuration Example
{
    param
    (
        [Parameter(Mandatory = $true)]
        [PSCredential]
        $SetupAccount
    )

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPLogLevel SetUserProfileLogingtoVerbose
        {
            Name                 = "SP_Database-Verbose"
            SPLogLevelSetting    = @(
                MSFT_SPLogLevelItem {
                    Area       = "SharePoint Server"
                    Name       = "Database"
                    TraceLevel = "Verbose"
                    EventLevel = "Verbose"
                }
            )
            PsDscRunAsCredential = $SetupAccount
        }
    }
}

Example 2

This example sets an entire Area to the default values

Configuration Example
{
    param
    (
        [Parameter(Mandatory = $true)]
        [PSCredential]
        $SetupAccount
    )

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPLogLevel SetAllSPServerToDefault
        {
            Name                 = "SPServer_defaults"
            SPLogLevelSetting    = @(
                MSFT_SPLogLevelItem {
                    Area       = "SharePoint Server"
                    Name       = "*"
                    TraceLevel = "Default"
                    EventLevel = "Default"
                }
            )
            PsDscRunAsCredential = $SetupAccount
        }
    }
}

Example 3

This example sets multiple items to custom values

Configuration Example
{
    param
    (
        [Parameter(Mandatory = $true)]
        [PSCredential]
        $SetupAccount
    )

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPLogLevel SetCustomValues
        {
            Name                 = "CustomLoggingSettings"
            SPLogLevelSetting    = @(
                MSFT_SPLogLevelItem {
                    Area       = "SharePoint Server"
                    Name       = "Database"
                    TraceLevel = "Verbose"
                    EventLevel = "Verbose"
                }
                MSFT_SPLogLevelItem {
                    Area       = "Business Connectivity Services"
                    Name       = "Business Data"
                    TraceLevel = "Unexpected"
                    EventLevel = "Error"
                }
            )
            PsDscRunAsCredential = $SetupAccount
        }
    }
}
Clone this wiki locally