Merging SharePoint ULS Log Files from multiple servers

Troubleshooting a SharePoint issue and tracking a correlation ID becomes all of the more cumbersome when the underlying SharePoint topology is spread across multiple web and application servers.

Running the Powershell command ‘Merge-SPLogFile will indeed merge and wrap the latest ULS logs into a single file, although this can become very large depending on your Farm activity and ultimately, may difficult to open and work with.

Ideally, you should restart the SharePoint Tracing Service, which in turn generates a new log file, and then replicate the issue once more to regenerate a correlation ID. Once merged, these new, smaller log files will then easy to analyse.

The simple Powershell script below should be run from a SharePoint server with your Farm and can be used to restart the Tracing service and consolidate the logs. There is a 2 minute ‘sleep’ cycle following the restart of the Tracing service, and this is when you should replicate the problem. If replicating is convoluted and may exceed 2 minutes, edit the script accordingly.

 

Write-Host “Restarting SharePoint Tracing Service across all Servers”

$targetcomputers = (“SPserver01″, ” SPserver02″, ” SPserver03″, ” SPserver04″)

$targetcomputers | % { Restart-Service -InputObject $(Get-Service -Computer $_ -Name SPTraceV4) }

Write-Host “Replicate issue to generate correlation ID”

Start-Sleep -s 120

Write-Host “Merge Log Files and generate output”

Merge-SPLogFile -Path “e:\merged.log” -overwrite

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s