Merge-SPLogFile: Merge SharePoint Log Files from Multiple Servers

Problem: In a multi-server SharePoint farm, if you need to trace an issue, you have to log in and review the ULS logs on each server in the farm. This process could be tedious in multi-server farms since you’re not sure on which server the error has occurred.

Merge-SPLogFile: Merge SharePoint Log Files from Multiple Servers

Solution:

Use the Merge-SPLogFile PowerShell cmdlet.

The Merge-SPLogFile cmdlet will consolidate the logs from all servers in the SharePoint farm into a single log file. You can run it from any server and it gathers data from the entire farm – to find issues.

Here are some examples of Merge-SPLogFile:

Extract LOG from all SharePoint Servers matching correlation ID:

Merge-SPLogFile -path "D:\ErrorLog.txt" -Correlation "Your-error-correlation-id"

Use the above cmdlet to fetch the ULS log for a given correlation ID from all SharePoint servers in a multiserver farm. Here, “path” refers to the log file name you want to create. If it already exists, use the “overwrite” switch. This cmdlet looks for logs within the past 20 Minutes of time span.

Merge-SPLogFile -Path D:\ErrorLog.txt -StartTime "20/10/2014" -overwrite

We can use parameters such as StartTime and/or EndTime parameters to specify the range of the log entries. There are other properties to help you narrow down the log search:

  • Area
  • Category
  • ContextFilter
  • Correlation
  • EndTime
  • EventID
  • Level
  • Message
  • Process
  • ThreadID
Tips: Use New-SPLogFile cmdlet to instruct SharePoint 2013 to start a new log file.

See the complete examples at Technet: Merge-SPLogFile Technet reference

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

One thought on “Merge-SPLogFile: Merge SharePoint Log Files from Multiple Servers

  • Hello Salaudeen

    Nice article. Is there any way to fetch the particular sub-site logs? or any script to achieve this?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *