Get-SPLogEvent

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

Syntax

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

Description

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.

For permissions and the most current information about Windows PowerShell for SharePoint Products, see the online documentation at SharePoint Server Cmdlets.

Examples

--------------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.

Parameters

-AssignmentCollection

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.

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.

Type:SPAssignmentCollection
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-AsString

Returns each record as a separate string

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-ContextKey

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

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Directory

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

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-EndTime

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.

Type:DateTime
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-File

Specifies a specific file to query records from.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-MinimumLevel

Returns records at or above the specified level. The valid values are Error or Warning.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-StartTime

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.

Type:DateTime
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition