跟踪和调试

事务集成器 (TI) 提供对 Windows 启动处理 (WIP) 调用和主机启动处理 (HIP) 调用的详细跟踪。 此跟踪是通过在应用配置文件以及描述应跟踪的内容的主机集成跟踪定义文件 (.hitd) 中启用跟踪来完成的。 可以通过 hitd 文件来启用和关闭跟踪。 也可通过应用配置文件来启用和关闭跟踪,但是,必须重启 TI 进程,新配置才能生效,因为系统只有在 TI 进程启动时才会读取应用配置文件。

以下说明介绍了如何利用位于 C:\Tracing 文件夹中的跟踪文件设置跟踪。 如有必要,可以使用其他文件夹,但运行 TI 进程的帐户必须对跟踪文件夹具有读/写访问权限。

  1. 创建跟踪文件夹 C:\Tracing

  2. 创建主机集成跟踪定义文件 (HITD)

  3. 启动跟踪查看器(必须安装 HIS):启动 - 运行 - histraceviewer

  4. 从“文件”菜单中,选择“新建定义文件”。 TI_Trc02b1

  5. 选择事务集成器 WIP: TI_Trc_02c

  6. 跟踪大小和选择:可以为每个组件设置跟踪级别。 如果在较高组件上设置了跟踪级别,则该跟踪级别也适用于从属组件。

    • 右键单击“跟踪级别”,然后选择“新建级别”。 TI_Trc_02d
    • 选择一个或多个级别,然后单击“确定”。 TI_Trc_02e
    • 选择所有选项将导致在单击“确定”后反映“全部”。 TI_Trc_02f
    • 将新的 HITD 文件作为 TI_Trace 保存在 C:\Tracing 目录中。 关闭跟踪查看器。 TI_Trc_02g
  7. 用跟踪配置信息更新应用程序配置文件。

    对于 Windows 启动的处理 (WIP) TI .Net 项目中的 app.config 可以使用跟踪配置信息进行修改,并在编译应用程序时包含在 <appname>.exe.config 文件中。 如果应用程序已编译, <则可以使用此信息直接修改 appname>.exe.config 文件。

    如果在 BizTalk 中使用主机应用程序 BizTalk 适配器 (BAHA),则必须修改的配置文件是 BizTalk 应用程序中为 BAHA 端口选择的 BizTalk 主机的 BizTalk Server exe 配置文件。 配置文件位于 %BTSINSTALLPATH% 中,其名称为 BTSNTSvc.exe.config 或 BTSNTSvc64.exe.config,具体取决于它是 BAHA 端口使用的 32 位还是 64 位主机进程。

    如果正在使用主机启动处理 (HIP),则必须修改的是 HIPService.exe.config 文件。 此文件位于 %SNAROOT%。

    在 configSections 元素中添加以下 section 语句。 如果 configSections 元素不存在,请添加该元素

    configSections> 语句必须紧接在配置>之后<和启动>节之前<。<

    对于 HIS 2016,请在 configSections 元素中输入以下行:

    <configSections>
       <section name="hostIntegration.tracing" type="Microsoft.HostIntegration.ConfigurationSectionHandlers.Tracing.TracingConfigurationSectionHandler, Microsoft.HostIntegration.ConfigurationSectionHandlers, Version=10.0.1000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </configSections>
    

    对于 HIS 2013,请在 configSections 元素中输入以下行(不同之处是版本更改):

    <configSections>
       <section name="hostIntegration.tracing" type="Microsoft.HostIntegration.ConfigurationSectionHandlers.Tracing.TracingConfigurationSectionHandler, Microsoft.HostIntegration.ConfigurationSectionHandlers, Version=9.0.1000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </configSections>
    

    将以下基本跟踪配置元素添加到 /configuration> 节结束语句前的配置节末尾的 <节:

    <hostIntegration.tracing xmlns="http://schemas.microsoft.com/HIS/Tracing/2020">
          <traceOptions traceDefinitionFile="C:\Tracing\TI_Trace.hitd"
                        writeTraceFile="true"
                        fileNamePreamble="TI_Tracing"
                        traceFileFolder="C:\Tracing\" />
          </hostIntegration.tracing>
    
  8. 执行应用程序以开始跟踪。 如果对应用程序配置文件进行了更改,则必须重启 TI 运行时所使用的进程,才能启用跟踪。 如果使用 BizTalk,则必须重启主机实例。 如果使用 IIS,则必须重启网站。 如果执行 .Net exe,则必须重启该程序。

    • 在 C:\Tracing 文件夹中查看一个或多个 HITF(主机集成跟踪文件)文件。 文件的名称将TI_Tracing_<process ID number>_<date and time.hitf>。 例如:

      TI_TRACING_6076_AUG_29_2017_13_00_52_421.HITF

    • 双击 HITF 文件以在跟踪查看器中打开该文件,并检查已跟踪的内容。 如果 TI 进程仍在缓冲区等位置运行某些跟踪信息,则退出应用程序或在应用程序中运行其他 TI 调用将刷新缓冲区,以查看第一个 TI 调用的整个跟踪。

          TBGen invoke entered for Class: BankingCicsElmLink.Accounts
          Non-Persistent
          Attempting to acquire library reader and load HIS object assembly
          Method: GetBalance
          Using configured RE for this object
          Remote Environment: ELM Link RE
          Aggregate Converter: Microsoft.HostIntegration.TI.AggregateConverter, Microsoft.HostIntegration.TI.AggregateConverter, Version=10.0.1000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
          Primitive Converter: Microsoft.HostIntegration.Common.BasePrimitiveConverter, Microsoft.HostIntegration.Common.BasePrimitiveConverter, Version=10.0.1000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
          Transport: Microsoft.HostIntegration.TI.ELMTransport, Microsoft.HostIntegration.TI.ELMTransport, Version=10.0.1000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
          State Machine: Microsoft.HostIntegration.TI.GenericLinkStateMachine, Microsoft.HostIntegration.TI.GenericLinkStateMachine, Version=10.0.1000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
          Invoking the state machine
          Generic Link state machine entered for method: GetBalance
          ELM Transport Initialized, Link: True, Codepage: 37
          Header length: 35
          Header Length: 35, Trailer Length: 0
          Non-Persistent
      
  9. 关闭跟踪

    • 在跟踪查看器中打开 TI_Trace.hitd 文件并删除跟踪级别。 保存 hitd 文件后将动态关闭跟踪。 无需重启 TI 应用程序。

各种场景下应用程序配置文件的示例

  • .Net WIP 应用程序的示例
      <?xml version="1.0"?>
      <configuration>
        <configSections>
          <section name="hostIntegration.ti.wip" type="Microsoft.HostIntegration.ConfigurationSectionHandlers.Ti.Wip.WipConfigurationSectionHandler, Microsoft.HostIntegration.ConfigurationSectionHandlers, Version=10.0.1000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
          <section name="hostIntegration.tracing" type="Microsoft.HostIntegration.ConfigurationSectionHandlers.Tracing.TracingConfigurationSectionHandler, Microsoft.HostIntegration.ConfigurationSectionHandlers, Version=10.0.1000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        </configSections>

        <hostIntegration.ti.wip xmlns="http://schemas.microsoft.com/his/Config/TiWip/2020">
          <readOrder appConfig="first" cache="unused" registry="unused"/>
          <remoteEnvironments>
            <remoteEnvironment isDefault="true" name="ELM Link RE" timeout="5" codePage="37">
              <elmLink ipAddress="localhost" ports="7511" requestHeaderFormat="Microsoft"/>
            </remoteEnvironment>
          </remoteEnvironments>
        </hostIntegration.ti.wip>

        <startup>
          <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
        </startup>

        <hostIntegration.tracing xmlns="http://schemas.microsoft.com/his/Tracing/2020">
          <traceOptions traceDefinitionFile="C:\Tracing\TI_Trace.hitd"
                        writeTraceFile="true"
                        fileNamePreamble="TI_Tracing"
                        traceFileFolder="C:\Tracing\" />
        </hostIntegration.tracing>
      </configuration>
  • 使用主机应用程序 BizTalk 适配器的 BizTalk 应用程序示例 - %BTSINSTALLPATH%\BTSNTSvc.exe.config 或 %BTSINSTALLPATH%\BTSNTSvc64.exe.config 文件:
    Here is my text
    
  • 使用 TI 运行时的 IIS 应用程序示例
    Here is my text
    
  • TI 主机启动处理 (HIP) 应用程序的示例 - %SNAROOT%\HIPService.exe.config 文件:
    Here is my text
    

另请参阅

SNA 跟踪实用工具 - 如果 TI 对象通过 Host Integration Server 网关使用 APPC,则可利用 SNA 跟踪实用工具。 该实用工具可捕获流经主机的 APPC 流量。 如果 TI 对象直接通过 TCP/IP 与主机系统通信,则无法使用此实用工具。