Get-SPLogEvent

从统一日志记录服务 (ULS) 跟踪日志返回结果。

语法

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

说明

此 cmdlet 包含多个参数集。 您可以只使用来自一个参数集的参数,也可以不合并来自不同参数集的参数。 若要详细了解如何使用参数集,请参阅 Cmdlet 参数集

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.

有关适用于 SharePoint 产品的 Windows PowerShell 的权限和最新信息,请参阅 SharePoint Server cmdlet

示例

--------------示例 1-----------------

Get-SPLogEvent -MinimumLevel "Warning"

此示例从默认日志目录中返回严重性大于等于警告的所有日志项。

--------------示例 2-----------------

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

此示例从 C:\Logs 目录中的日志文件返回所有警告项。

--------------示例 3-----------------

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

此示例返回特定时间范围(美国的区域性特定范围)内发生的错误项。

--------------示例 4-----------------

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

此示例返回最新日志文件的内容,并添加指定的 Context Key 数据。

--------------示例 5-----------------

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

此示例返回与 SharePoint Foundation 相关的所有错误项。

--------------示例 6-----------------

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

此示例返回日志文件的内容并添加上下文数据。

参数

-AsString

将每条记录作为单独字符串返回

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

-ContextKey

指定应将上下文数据添加到指定上下文键的结果中,例如: -ContextKey @("UserName", "SiteName")

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

-Directory

列出备用目录(除了已配置的 LogLocation 目录之外的任何目录)中的日志文件。

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

-EndTime

键入的值必须是管理语言的区域性特定的有效日期时间格式,如美国英语的日期时间格式为 2/16/2007 12:15:12。

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

-File

指定来自查询记录的特定文件。

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

-MinimumLevel

返回指定级别或以上的记录。 有效值为“错误”或“警告”。

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

-StartTime

键入的值必须是管理语言的区域性特定的有效日期时间格式,如美国英语的日期时间格式为 2/16/2007 12:15:12。

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

-工作分配

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
Accept pipeline input:True
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition