powershell_2Download script Here: mergesplogfile

If you’re a SharePoint Administrator something you probably learned pretty early in your adventure is if there’s an error or problem. CHECK YOUR LOGS! APP LOGS, SYS LOGS, EVENT LOGS, ULS Logs, etc… There’s a saying that “LOGS DON’T LIE!” And I believe that to be accurate 99% of the time. Albeit of those logs are often as clear as mud…. Perhaps interviewers should be looking for people who have the skillset “fluent in reading logs” on their resume.

Anyways, with SharePoint the best log source would be those produced by the Unified Logging Service, or ULS. Those are by default those logs are stored at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\(Hive)Logs But any admin worth their weight in donuts will immediately find another drive to write these logs to as they can, and will do their best to eat up every available bit of drive space you have available, particularly when you use the VERBOSE setting. If there’s a SharePoint issue, most likely you’ll find the culprit and root cause in the ULS log.

If you have a multi farm environment, then each one of those servers gets it’s own set of ULS logs. This is great because if your search server is angry and logging a ton of search related stuff in it’s ULS folder, your Web Front End Server doesn’t have to suffer with all those search writes. This is also horrible, because now you have to look at multiple locations to figure out where that correlation ID wrote itself to, or to get ALL the Logs from ALL the servers about a particular issue. Maybe you have 1 misbehaving WFE, now it’s guess which one is acting up. All in all it just slows you down. Well in SharePoint 2010 Microsoft introduced a PowerShell cmdlet that merges the logfile from all of the Servers into 1 single file and exports it to a location. This was a HUGE HUGE plus to admins everywhere!  If you want more information about the Merge-SPLogfile command go here. https://technet.microsoft.com/en-us/library/ff607721.aspx

Now I use Merge-SPLogfile daily, sometimes multiple times per hour, and when I’m really trying to track down an issue, I may run it back to back to back to …. well you get the idea.

What I dislike is having to type out the command: merge-splogfile -correlation “RandomGuidGoesHere” -path “Ihopethisfolderpathhereiscorrect”  every single time that run the command, so I wrote a really simple script to make things a tad bit faster. It prompts you for which operation you’d like to use. The filename you want it to save as, adds a timestamp to that name, in case you need 10 files named “StupidServer.txt”

Hopefully someone can find it useful. Right now it only includes the operations to merge based on a correlation ID and a StartTime and EndTime. Should be really easy to update this to support additional operations.

Anyways here ya go. Just save this as a .ps1 file, update the $LogFileFolder variable and give it a run. Pretty self explanatory.
Download script Here: mergesplogfile

Hope it’s helpful and Happy SharePointing

(491)

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.