During Troubleshooting and specially working with Microsoft Support team we have to collect logs from all servers in the farm and send it to them. The issue is that these logs will have more information than what we have with out issue. So there is the best option.
- Create a File
- Enable Verbose Ex or Verbose Logging
- Reproduce the issue
- Disable Verbose Ex or Verbose Logging
- Merge the Log Files
Luckily the script below will do that.
Note: The output file will grow very large in case the issue has multiple steps for repduction + VerboseEx logging produce lot of extra information. Change the verbose if you are not looking for EX.
save the below script as Ps1 and you are ready.
#Title: ULS Collector #Description: This script will collect the ULS logs by way of merging them from every server. #Add SharePoint Snapin Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Set file location $path = Read-Host "Please enter the full path for the log file along with the file name"; #Increase logging to verbose Write-Host "Increasing ULS logging to VerboseEx..."; Set-SPLogLevel -TraceSeverity VerboseEx -EventSeverity Verbose; #Prompting to start and setting the start time Read-Host "Hit enter to start, then reproduce the issue" $starttime = Get-Date -Format "MM/dd/yyyy HH:mm:ss" Write-Host "The start time for the log file is $starttime"; #Prompting to stop and setting the end time Read-Host "Hit enter to end" $endtime = Get-Date -Format "MM/dd/yyyy HH:mm:ss" Write-Host "The ending time for the log file is $endtime"; #Setting the log level back to normal Clear-SPLogLevel #Merging the logs to the specified path using the start and end times Merge-SPLogFile -Path $path -Overwrite -StartTime $starttime -EndTime $endtime; Write-Host "Logs have been collected. Resetting the log level back to normal." New-SPLogFile