ULS Logging – Part 2

A better way is to use Get-SPLogEvent’s -StartTime parameter to limit the events it reads. The following command returns the last ten events in the last five minutes:

Get-SPLogEvent -StartTime (get-date).addminutes(-5) | Select -Last 10

In most cases, when you use Get-SPLogEvent, it will be to get all of the events for a particular correlation ID.

Get-SPLogEvent -StartTime (Get-Date).addminutes(-10) | Where-Object {$_.correlation -eq “00000000-0000-0000-0000-000000000000”}

With this method you can quickly get the log event entries that you’re looking for.

New-SPLogFile: tells SharePoint to close out the current log file and create a new one.

Merge-SPLogFile: merge the trace logs from all of the SharePoint servers in your farm into one log file. By default, Merge-SPLogFile only merges events from the last hour
from each machine
. You can use –StartTime, -EndTime
to customize the tiem range. it creates a timer job on all of the machines in the farm. This timer job collects the logs requested, and then copies them over to the server where Merge-SPLogFile is running.


Syntax: Merge-SPLogFile –Path farm.log

Syntax: Merge-SPLogFile –Path farm.log –Correlation “9ed2h-d94-234123fdf-234e-asfasdfds”

This will only merge the log entries that belong to this Correlation ID.

Good for (1) troublshoorting, and also for (2) archiving log files.

Advertisements
Post a comment or leave a trackback: Trackback URL.

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

%d bloggers like this: