Modify path for IIS and SharePoint logging

$IISLoggingPath  = "D:\logs\IIS"
$SPDiagnosticsLoggingPath  = "D:\logs\Diagnostics"
$SPUsageLoggingPath  = "D:\logs\Usage"
$SPLogDiskSpaceUsageGB  = 30

if (!(Test-Path -path $IISLoggingPath)) { New-Item -ItemType directory -Path $IISLoggingPath | out-null}
if (!(Test-Path -path $SPDiagnosticsLoggingPath)) { New-Item -ItemType directory -Path $SPDiagnosticsLoggingPath | out-null}
if (!(Test-Path -path $SPUsageLoggingPath)) { New-Item -ItemType directory -Path $SPUsageLoggingPath | out-null}

set-SPDiagnosticConfig -LogLocation $SPDiagnosticsLoggingPath -LogDiskSpaceUsageGB $SPLogDiskSpaceUsageGB
set-SPUsageService -UsageLogLocation $SPUsageLoggingPath

Set-WebConfigurationProperty "/system.applicationHost/sites/siteDefaults" -name logfile.directory -value $IISLoggingPath

Leave a Reply

Your email address will not be published.