Export (0) Print
Expand All
1 out of 3 rated this helpful - Rate this topic

Get-SPLogEvent

 

Applies to: SharePoint Server 2013 Enterprise, SharePoint Foundation 2013

Topic Last Modified: 2014-02-20

Returns results from a Unified Logging Service (ULS) trace log.

Get-SPLogEvent [-AssignmentCollection <SPAssignmentCollection>] [-AsString <SwitchParameter>] [-ContextKey <String[]>] [-Directory <String>] [-EndTime <DateTime>] [-MinimumLevel <String>] [-StartTime <DateTime>]
Get-SPLogEvent [-AssignmentCollection <SPAssignmentCollection>] [-AsString <SwitchParameter>] [-ContextKey <String[]>] [-EndTime <DateTime>] [-File <String>] [-MinimumLevel <String>] [-StartTime <DateTime>]

This cmdlet contains more than one parameter set. You may only use parameters from one parameter set, and you may not combine parameters from different parameter sets. For more information about how to use parameter sets, see Cmdlet Parameter Sets.

The Get-SPLogEvent cmdlet returns records from a ULS trace log file that match the criteria. If no parameters are specified, all records from all log files are returned. Use the StartTime and EndTime parameters to filter on a time range. The use of these parameters is recommended to optimize performance of this cmdlet.

 

Parameter Required Type Description

AssignmentCollection

Optional

Microsoft.SharePoint.PowerShell.SPAssignmentColletion

Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.

NoteNote:
When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.

AsString

Optional

System.Management.Automation.SwitchParameter

Returns each record as a separate string

ContextKey

Optional

System.String[]

Specifies that context data should be added to the results for the specified Context Keys, for example: -ContextKey @("UserName", "SiteName").

Directory

Optional

System.String

Lists log files from an alternate directory (any directory other than the configured LogLocation directory).

MinimumLevel

Optional

System.String

Returns records at or above the specified level. The valid values are (in order of severity): Information, Medium, High, Verbose, VerboseEx, Monitorable, Warning, Error, Critical, or Unassigned.

EndTime

Optional

System.DateTime

The type must be a valid DateTime format that is culture-specific to the administrative language, such as 2/16/2007 12:15:12 for English-US.

File

Optional

System.String

Specifies a specific file to query records from.

StartTime

Optional

System.DateTime

The type must be a valid DateTime format that is culture-specific to the administrative language, such as 2/16/2007 12:15:12 for English-US.

--------------EXAMPLE 1-----------------

Get-SPLogEvent -MinimumLevel "Warning"

This example returns all log entries equal to or more severe than Warning from the default log directory.

--------------EXAMPLE 2-----------------

Get-SPLogEvent -Directory "C:\Logs" | Where-Object {$_.Level -eq "Warning"}

This example returns all warning entries from log files in the C:\Logs directory.

--------------EXAMPLE 3-----------------

Get-SPLogEvent -StartTime "12/04/2007 17:00" -EndTime "12/04/2007 18:00"

This example returns error entries that occurred during a particular time range, which is culture-specific to the United States.

--------------EXAMPLE 4-----------------

Get-SPLogEvent -ContextKey @("UserName" ,"SiteName")

This example returns the contents of the most recent log file and adds the specified context key data.

--------------EXAMPLE 5-----------------

Get-SPLogEvent | Where-Object {$_.Level -eq "Error" -and {$_.Area -eq "SharePoint Foundation "}

This example returns all error entries related to SharePoint Foundation.

--------------EXAMPLE 6-----------------

Get-SPLogEvent -ContextKey @("Name") | %{$_.ToString() + "'t" + $_.Context["Name"]}

This example returns the contents of the log file and adds context data.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.