Testing

webTiger Logo Wide

How To Merge SharePoint ULS Logs From All Servers in the Farm

SharePoint 2013 Logo

There are going to be lots of occasions when you are going to want to merge the ULS logs from the individual SharePoint server instances that constitute your SharePoint farm. Fortunately, Microsoft provide a handy PowerShell command for just that purpose.

Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
Merge-SPLogFile -Path "your-folder\combined.log" -StartTime "28/09/2018 09:00" -EndTime "28/09/2018 10:00"Code language: JavaScript (javascript)

Adjust the dates/times as necessary!

Or, the following script helpfully grabs all logs for the last 5 minutes, saving it to a date/time based log file in the current working directory:

Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
$currentFolder = Get-Location
$logFilePath = [System.IO.Path]::Combine($currentFolder, "$(Get-Date -Format "yyyy-MM-dd-HHmmss")-MergedULS.log")
$until = Get-Date
$from = $until.AddMinutes(-5)
Merge-SPLogFile -Path $logFilePath -StartTime $from -EndTime $untilCode language: PHP (php)

Use this merge tool with care as log files can become very large, very quickly, if querying over large time periods.