在 Lync Server 2013 中配置集中日志记录服务的方案Configuring scenarios for the Centralized Logging Service in Lync Server 2013

 

上次修改的主题: 2014-02-05Topic Last Modified: 2014-02-05

方案定义了作用域 (即全局、站点、池或计算机) 以及要在集中日志记录服务中使用的提供程序。Scenarios define the scope (that is, global, site, pool, or computer) and what providers to use in the Centralized Logging Service. 通过使用方案,可以启用或禁用对提供程序进行的跟踪(例如,S4、SIPStack、IM 和 Presence)。By using scenarios, you enable or disable tracing on providers (for example, S4, SIPStack, IM, and Presence). 通过配置方案,可将针对给定逻辑集合的、满足某个特定问题条件的所有提供程序组合在一起。By configuring a scenario, you can group all of the providers for a given logical collection that address a specific problem condition. 如果发现需要修改某个方案以满足故障排除和日志记录需求,Lync Server 2013 调试工具会为您提供一个名为 ClsController 的 Windows PowerShell 模块,其中包含名为 Edit-new-csclsscenario的函数。If you find that a scenario needs to be modified to meet your troubleshooting and logging needs, the Lync Server 2013 Debug Tools provides you a Windows PowerShell module named ClsController.psm1 that contains a function named Edit-CsClsScenario. 此模块的用途是编辑命名的方案的属性。The purpose of the module is to edit the properties of the named scenario. 本主题提供了此模块的工作方式的示例。Examples of how this module works are provided in this topic. 从以下链接下载 Lync Server 2013 调试工具: https://go.microsoft.com/fwlink/?LinkId=285257The Lync Server 2013 Debug Tools are downloaded from the following link: https://go.microsoft.com/fwlink/?LinkId=285257

重要

对于任何给定的范围(站点、全局、池或计算机),您可以在任何给定时间最多运行两个方案。For any given scope—site, global, pool or computer—you can run a maximum of two scenarios at any given time. 若要确定当前正在运行的方案,请使用 Windows PowerShell 和 new-csclsscenarioTo determine which scenarios are currently running, use Windows PowerShell and Get-CsClsScenario. 通过使用 Windows PowerShell 和 new-csclsscenario,您可以动态更改正在运行的方案。By using Windows PowerShell and Set-CsClsScenario, you can dynamically change which scenarios are running. 可以在日志记录会话期间修改正在运行的方案,以调整或优化所收集的数据以及源提供程序。You can modify which scenarios are running during a logging session to adjust or refine the data you are collecting and from which providers.

若要使用 Lync Server 命令行管理程序运行集中式日志记录服务功能,您必须是 CsAdministrator 或 CsServerAdministrator 基于角色的访问控制 (RBAC) 安全组的成员,或者是包含这两个组中任一组的自定义 RBAC 角色。To run the Centralized Logging Service functions by using the Lync Server Management Shell, you must be a member of either the CsAdministrator or the CsServerAdministrator role-based access control (RBAC) security groups, or a custom RBAC role that contains either of these two groups. 若要返回此 cmdlet 已分配到的所有 RBAC 角色的列表,包括您自己创建的任何自定义 RBAC 角色,请从 Lync Server 命令行管理程序或 Windows PowerShell 提示符处运行以下命令:To return a list of all the RBAC roles this cmdlet has been assigned to, including any custom RBAC roles you have created yourself, run the following command from the Lync Server Management Shell or the Windows PowerShell prompt:

Get-CsAdminRole | Where-Object {$_.Cmdlets -match "Lync Server 2013 cmdlet"}

例如:For example:

Get-CsAdminRole | Where-Object {$_.Cmdlets -match "Set-CsClsConfiguration"}

本主题的其余部分重点说明了如何定义方案、修改方案、检索正在运行的方案、删除方案以及指定方案为优化故障排除而包含的内容。The remainder of this topic focuses on how to define a scenario, modify a scenario, retrieve what scenarios are running, remove a scenario, and specify what a scenario contains to optimize your troubleshooting. 有两种方法可以发出集中式日志记录服务命令。There are two ways to issue Centralized Logging Service commands. 默认情况下,您可以使用目录 C: \ Program files \ Common files The \ Microsoft Lync Server 2013 CLSAgent 中的 CLSController.exe \ 。You can use the CLSController.exe that is located, by default, in the directory C:\Program Files\Common Files\Microsoft Lync Server 2013\CLSAgent. 或者,您可以使用 Lync Server 命令行管理程序发出 Windows PowerShell 命令。Or, you can use the Lync Server Management Shell to issue Windows PowerShell commands. 重要区别在于,在命令行上使用 CLSController.exe 时,可供选择的可用方案是有限的。The important distinction is that when you use CLSController.exe at the command line there is a finite selection of scenarios available. 使用 Windows PowerShell 时,可以定义在日志记录会话中使用的新方案。When you use Windows PowerShell, you can define new scenarios for use in your logging sessions.

Lync Server 2013 中的集中日志记录服务概述中所述,方案的元素为:As introduced in Overview of the Centralized Logging Service in Lync Server 2013, the elements of a scenario are:

  • 提供程序    如果您熟悉 OCSLogger,则提供程序是您选择的组件,用于告诉 OCSLogger 跟踪引擎应从什么方面收集日志。Providers   If you are familiar with OCSLogger, providers are the components that you choose to tell OCSLogger what the tracing engine should collect logs from. 提供程序是一些相同的组件,在许多情况下,它们的名称与 OCSLogger 中组件的名称相同。The providers are the same components, and in many cases have the same name as the components in OCSLogger. 如果您不熟悉 OCSLogger,则提供程序是集中式日志记录服务可从中收集日志的特定于服务器角色的组件。If you are not familiar with OCSLogger, providers are server role specific components that the Centralized Logging Service can collect logs from. 有关提供程序配置的详细信息,请参阅 在 Lync Server 2013 中配置集中日志记录服务的提供程序For details about the configuration of providers, see Configuring providers for Centralized Logging Service in Lync Server 2013.

  • 标识    参数– Identity 设置方案的范围和名称。Identity   The parameter –Identity sets the scope and name of the scenario. 例如,您可以设置“全局”范围并使用“LyssServiceScenario”标识方案。For example, you could set a scope of “global” and identify the scenario with “LyssServiceScenario”. 在将二者组合在一起时,可以定义 Identity(例如“global/LyssServiceScenario”)。When you combine the two, you define the Identity (for example, “global/LyssServiceScenario”).

    (可选)可以使用 –Name 和 –Parent 参数。定义 Name 参数可对方案进行唯一标识。如果使用 Name,则还必须使用 Parent 将方案添加到全局或站点范围中。Optionally, you can use the –Name and –Parent parameters. You define the Name parameter to uniquely identify the scenario. If you use Name, you must also use Parent to add the scenario to either global or site.

    重要

    如果使用 Name 和 Parent 参数,则无法使用 –Identity 参数。If you use the Name and Parent parameters, you cannot use the –Identity parameter.

使用 New-CsClsScenario cmdlet 创建新的方案To create a new scenario with the New-CsClsScenario cmdlet

  1. 启动 Lync Server 命令行管理程序:依次单击“开始”****、“所有程序”****、“Microsoft Lync Server 2013”**** 和“Lync Server 命令行管理程序”****。Start the Lync Server Management Shell: Click Start, click All Programs, click Microsoft Lync Server 2013, and then click Lync Server Management Shell.

  2. 若要为日志记录会话创建新的方案,请使用 New-CsClsProvider 并定义方案的名称(即,对方案进行唯一标识的方式)。To create a new scenario for a logging session, use New-CsClsProvider and define the name of the scenario (that is, how it will be uniquely identified). 从 WPP 中选择日志记录格式的类型(即,Windows 软件跟踪预处理器和其默认值)、EventLog(即,Windows 事件日志格式)或 IISLog(即,基于 IIS 日志文件格式的 ASCII 格式文件)。Choose a type of logging format from WPP (that is, Windows software tracing preprocessor and is the default), EventLog (that is, Windows event log format), or IISLog (that is, ASCII format file based on the IIS log file format). 然后,定义级别(如本主题中的“日志记录级别”下所述)和标志(如本主题中的“标志”下所述)。Next, define Level (as the defined under Logging Levels in this topic), and Flags (as defined under Flags in this topic).

    对于此示例方案,我们将 LyssProvider 用作示例提供程序变量。For this example scenario, we use LyssProvider as the example provider variable.

    若要使用定义的选项创建方案,请键入:To create a scenario using the options defined, type:

    New-CsClsScenario -Identity <scope>/<unique scenario name> -Provider <provider variable>
    

    例如:For example:

    New-CsClsScenario -Identity "site:Redmond/LyssServiceScenario" -Provider $LyssProvider
    

    使用 –Name 和 –Parent 的备用格式:The alternate format using –Name and –Parent:

    New-CsClsScenario -Name "LyssServiceScenario" -Parent "site:Redmond" -Provider $LyssProvider
    

使用带 New-CsClsScenario cmdlet 的多个提供程序创建新的方案To create a new scenario with multiple providers with the New-CsClsScenario cmdlet

  1. 启动 Lync Server 命令行管理程序:依次单击“开始”****、“所有程序”****、“Microsoft Lync Server 2013”**** 和“Lync Server 命令行管理程序”****。Start the Lync Server Management Shell: Click Start, click All Programs, click Microsoft Lync Server 2013, and then click Lync Server Management Shell.

  2. 每个范围只能有两个方案。You are limited to two scenarios per scope. 但是,不限于设置的提供程序数。However, you are not limited to a set number of providers. 在此示例中,假定我们已创建三个提供程序,并且您希望将所有这三个提供程序分配给所定义的方案。In this example, assume that we have created three providers, and you want to assign all three to the scenario you are defining. 提供程序变量名称为 LyssProvider、ABServerProvider 和 SIPStackProvider。The provider variable names are LyssProvider, ABServerProvider, and SIPStackProvider. 若要定义多个提供程序并将其分配给某个方案,请在 Lync Server 命令行管理程序或 Windows PowerShell 命令提示符处键入以下内容:To define and assign multiple providers to a scenario, type the following at a Lync Server Management Shell or Windows PowerShell command prompt:

    New-CsClsScenario -Identity "site:Redmond/CollectDataScenario" -Provider @{Add=$LyssProvider, $ABServerProvider,  $SIPStackProvider}
    

    备注

    在 Windows PowerShell 中,创建使用的值的哈希表的约定 @{<variable>=<value1>, <value2>, <value>...} 称为 " 展开"。As it is known in Windows PowerShell, the convention for creating a hash table of values using @{<variable>=<value1>, <value2>, <value>...} is known as splatting. 有关 Windows PowerShell 中的展开的详细信息,请参阅 https://go.microsoft.com/fwlink/p/?LinkId=267760For details about splatting in Windows PowerShell, see https://go.microsoft.com/fwlink/p/?LinkId=267760.

使用 Set-CsClsScenario cmdlet 修改现有方案To modify an existing scenario with the Set-CsClsScenario cmdlet

  1. 启动 Lync Server 命令行管理程序:依次单击“开始”****、“所有程序”****、“Microsoft Lync Server 2013”**** 和“Lync Server 命令行管理程序”****。Start the Lync Server Management Shell: Click Start, click All Programs, click Microsoft Lync Server 2013, and then click Lync Server Management Shell.

  2. 每个范围只能有两个方案。您可以随时更改正在运行的方案,即使日志记录捕获会话正在进行中也是如此。如果您重新定义正在运行的方案,则当前日志记录会话将停止使用已删除的方案,并开始使用新方案。但是,已通过删除的方案捕获到的日志记录信息将保留在捕获的日志中。若要定义新的方案,请执行下列命令(即,假定添加一个名为“S4Provider”的已定义的提供程序):You are limited to two scenarios per scope. You can change which scenarios are running at any time, even when a logging capture session is in process. If you redefine the running scenarios, the current logging session will stop using the scenario that was removed and then begin using the new scenario. However, the logging information that was captured with the removed scenario remains in the captured logs. To define a new scenario, do the following (that is, assuming the addition of an already defined provider named “S4Provider”):

    Set-CsClsScenario -Identity <name of scope and scenario defined by New-CsClsScenario> -Provider @{Add=<new provider to add>}
    

    例如:For example:

    Set-CsClsScenario -Identity "site:Redmond/LyssServiceScenario" -Provider @{Add=$S4Provider}
    

    若要替换提供程序,请定义一个提供程序或一个以逗号分隔的提供程序列表来替换当前集。如果您只需要替换多个提供程序之一,请将当前提供程序与新的提供程序一起添加以创建同时包含新提供程序和现有提供程序的新提供程序集。若要将所有提供程序替换为新集,请键入:If you want to replace providers, define a single provider or a comma separated list of providers to replace the current set. If you only want to replace one of many providers, add the current providers with the new providers to create a new set of providers that contains both new providers and existing providers. To replace all providers with a new set, type the following:

    Set-CsClsScenario -Identity <name of scope and scenario defined by New-CsClsScenario> -Provider @{Replace=<providers to replace existing provider set>}
    

    例如,将 $LyssProvider、$ABServerProvider 和 $SIPStackProvider 的当前集替换为 $LyssServiceProvider:For example, to replace the current set of $LyssProvider, $ABServerProvider, and $SIPStackProvider with $LyssServiceProvider:

    Set-CsClsScenario -Identity "site:Redmond/LyssServiceScenario" -Provider @{Replace=$LyssServiceProvider}
    

    若只将 $LyssProvider、$ABServerProvider 和 $SIPStackProvider 的当前集中的 $LyssProvider 提供程序替换为 $LyssServiceProvider,请键入:To replace just the $LyssProvider provider from the current set of $LyssProvider, $ABServerProvider, and $SIPStackProvider with $LyssServiceProvider, type the following:

    Set-CsClsScenario -Identity "site:Redmond/LyssServiceScenario" -Provider @{Replace=$LyssServiceProvider, $ABServerProvider, $SIPStackProvider}
    

使用 Remove-CsClsScenario cmdlet 删除现有方案To remove an existing scenario with the Remove-CsClsScenario cmdlet

  1. 启动 Lync Server 命令行管理程序:依次单击“开始”****、“所有程序”****、“Microsoft Lync Server 2013”**** 和“Lync Server 命令行管理程序”****。Start the Lync Server Management Shell: Click Start, click All Programs, click Microsoft Lync Server 2013, and then click Lync Server Management Shell.

  2. 若要删除之前已定义的方案,请键入:If you want to remove a scenario that has been previously defined, type the following:

    Remove-CsClsScenario -Identity <name of scope and scenario>
    

    例如,删除定义的方案 site:Redmond/LyssServiceScenario:For example, to remove the defined scenario site:Redmond/LyssServiceScenario:

    Remove-CsClsScenario -Identity "site:Redmond/LyssServiceScenario"
    

Remove-CsClsScenario cmdlet 可删除指定的方案,但已捕获的跟踪信息仍将保留在日志中以供您搜索。The Remove-CsClsScenario cmdlet removes the specified scenario, but the traces that have been captured are still available in the logs for you to search on.

使用 ClsController.psm1 模块加载和卸载 Edit-CsClsScenario cmdletTo load and unload the Edit-CsClsScenario cmdlet using the ClsController.psm1 module

  1. 启动 Lync Server 命令行管理程序:依次单击“开始”****、“所有程序”****、“Microsoft Lync Server 2013”**** 和“Lync Server 命令行管理程序”****。Start the Lync Server Management Shell: Click Start, click All Programs, click Microsoft Lync Server 2013, and then click Lync Server Management Shell.

    重要

    ClsController.psm1 模块是作为单独的 Web 下载提供的。The ClsController.psm1 module is provided as a separate Web download. 模块是 Lync Server 2013 调试工具的一部分。The module is part of the Lync Server 2013 Debugging tools. 默认情况下,调试工具将安装到目录 C:\Program Files\Lync Server 2013\Debugging Tools 中。By default, the debugging tools are installed in the directory C:\Program Files\Lync Server 2013\Debugging Tools.

  2. 在 Windows PowerShell 中,键入:From the Windows PowerShell, type:

    Import-Module "C:\Program Files\Lync Server 2013\Debugging Tools\ClsController.psm1"
    

    提示

    成功加载该模块后,将返回到 Windows PowerShell 命令提示符。Successful loading of the module returns you to the Windows PowerShell command prompt. 若要确认模块已加载且 Edit-CsClsScenario 可用,请键入 Get-Help Edit-CsClsScenarioTo confirm that the module is loaded and that Edit-CsClsScenario is available, type Get-Help Edit-CsClsScenario. 您应看到 EditCsClsScenario 的语法的基本概要。You should see the basic synopsis of the syntax for EditCsClsScenario.

  3. 若要卸载模块,请键入:To unload the modules, type:

    Remove-Module ClsController
    

    提示

    成功卸载该模块后,将返回到 Windows PowerShell 命令提示符。Successful unloading of the module returns you to the Windows PowerShell command prompt. 若要确认模块已卸载,请键入 Get-Help Edit-CsClsScenarioTo confirm that the module is unloaded, type Get-Help Edit-CsClsScenario. Windows PowerShell 将尝试查找 cmdlet 的帮助并失败。Windows PowerShell will attempt to locate the help for the cmdlet and fail.

使用 Edit-ClsController 模块从方案中删除现有提供程序To remove an existing provider from a scenario with the Edit-ClsController module

  1. 启动 Lync Server 命令行管理程序:依次单击“开始”****、“所有程序”****、“Microsoft Lync Server 2013”**** 和“Lync Server 命令行管理程序”****。Start the Lync Server Management Shell: Click Start, click All Programs, click Microsoft Lync Server 2013, and then click Lync Server Management Shell.

  2. 若要从 AlwaysOn 方案中删除提供程序,请键入:To remove a provider from the AlwaysOn scenario, type:

    Edit-CsClsScenario -ScenarioName <string of the scenario to edit> -ProviderName <string of the provider to remove> -Remove
    

    例如:For Example:

    Edit-CsClsScenario -ScenarioName AlwaysOn -ProviderName ChatServer -Remove
    

    参数 ScenarioName 和 ProviderName 是定位参数(也就是说,必须在命令行中的预期位置定义这两个参数)。如果相对于位置 1 的 cmdlet 的名称,方案名称位于位置 2 且提供程序位于位置 3,则无需显式定义参数名称。通过使用此信息,可以按以下形式键入上一个命令:The parameters ScenarioName and ProviderName are positional (that is, they must be defined in the expected position in the command line) parameters. The parameter name does not have to be explicitly defined if the scenario name is in position two and the provider is in position three, relative to the name of the cmdlet as position one. Using this information, the previous command would be typed as:

    Edit-CsClsScenario AlwaysOn ChatServer -Remove
    

    参数值的定位放置仅适用于 –Scenario 和 –Provider。必须显式定义所有其他参数。The positional placing of the parameter values applies only to –Scenario and –Provider. All other parameters must be explicitly defined.

使用 Edit-ClsController 模块将提供程序添加到方案To add a provider to a scenario with the Edit-ClsController module

  1. 启动 Lync Server 命令行管理程序:依次单击“开始”****、“所有程序”****、“Microsoft Lync Server 2013”**** 和“Lync Server 命令行管理程序”****。Start the Lync Server Management Shell: Click Start, click All Programs, click Microsoft Lync Server 2013, and then click Lync Server Management Shell.

  2. 若要将提供程序添加到 AlwaysOn 方案,请键入:To add a provider to the AlwaysOn scenario, type:

    Edit-CsClsScenario -ScenarioName <string of the scenario to edit> -ProviderName <string of the provider to add> -Level <string of type level> -Flags <string of type flags>
    

    例如:For Example:

    Edit-CsClsScenario -ScenarioName AlwaysOn -ProviderName ChatServer -Level Info -Flags TF_COMPONENT
    

    -Loglevel 可以是 "致命"、"错误"、"警告"、"信息"、"详细"、"调试" 或 "全部"。-Loglevel can be of the type Fatal, Error, Warning, Info, Verbose, Debug, or All. – Flags 可以是提供程序支持的任何标志,如 TF _ COMPONENT、tf _ 诊断。–Flags can be any of the flags that the provider supports, such as TF_COMPONENT, TF_DIAG. –Flags 的值可以为 ALL–Flags can also be of value ALL

    还可以使用 cmdlet 的定位功能键入上一个示例。例如,若要将提供程序 ChatServer 添加到 AlwaysOn 方案,请键入:The previous example can also be typed using the positional feature of the cmdlet. For example, to add the provider ChatServer to the AlwaysOn scenario, type:

    Edit-CsClsScenario AlwaysOn ChatServer -Level Info -Flags ALL