Skip to content

SPLogLevel

Yorick Kuijs edited this page Nov 8, 2018 · 11 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 String[] Collection of SPLogLevelItems to set
InstallAccount Write PSCredential POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsCredential if using PowerShell 5

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