追蹤和偵錯

交易整合器 (TI) 提供 WINDOWS 起始處理 (WIP) 呼叫和主機起始處理 (HIP) 呼叫的詳細追蹤。 此追蹤是透過在應用程式組態檔中啟用追蹤以及主機整合追蹤定義檔案 (.hitd) 來完成,以描述應該追蹤的內容。 追蹤可以透過點擊的檔案開啟和關閉。 追蹤也可能透過應用程式組態檔開啟和關閉,不過,必須重新開機 TI 程式,新的組態才會生效,因為只有在啟動 TI 程式時才會讀取應用程式組態檔。

下列指示示範如何設定追蹤檔案將位於 C:\Trace 資料夾中的追蹤位置。 如有需要,可以使用不同的資料夾 - 執行 TI 進程的帳戶必須具有追蹤資料夾的讀取/寫入權限。

  1. 建立追蹤資料夾 C:\Tracing

  2. 建立主機整合追蹤定義檔案 (HITD)

  3. 啟動追蹤檢視器 (HIS 必須安裝) :Start - Run - histraceviewer

  4. 從 [檔案] 功能表中,選取 [新增定義檔案]。 TI_Trc02b1

  5. 選取交易整合器 WIP: TI_Trc_02c

  6. 追蹤大小和選取專案:您可以為每個元件設定追蹤層級。 如果追蹤層級是在較高的元件上設定,則該追蹤層級也適用于次級元件。

    • 以滑鼠右鍵按一下 [追蹤層級],然後選取 [新增層級]。 TI_Trc_02d
    • 選取一或多個層級,然後按一下 [確定]。 TI_Trc_02e
    • 選取所有選項會導致在按一下 [確定] 之後反映 「ALL」。 TI_Trc_02f
    • 將新的 HITD 檔案儲存為 C:\Tracing 目錄中的 TI_Trace。 關閉追蹤檢視器。 TI_Trc_02g
  7. 使用追蹤組態資訊更新應用程式組態檔。

    針對 Windows 起始處理 (WIP) TI .Net 專案中的 app.config,可以使用追蹤組態資訊進行修改,並在編譯應用程式時包含在 < appname > .exe.config 檔案中。 如果應用程式已經編譯, < 則可以直接使用這項資訊修改 appname > .exe.config 檔案。

    如果 BizTalk 配接器 for Host Applications (B要用於 BizTalk) ,則必須修改的組態檔是針對 BizTalk 應用程式內針對 BOT 埠選取的 BizTalk 主機的 BizTalk Server exe 設定檔。 組態檔位於 %BTSINSTALLPATH%,而且根據 BOWED 埠正在使用的 32 位或 64 位主機進程,其名稱為 BTSNTSvc.exe.config 或 BTSNTSvc64.exe.config。

    如果使用 HOST 起始處理 (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:\Trace 資料夾,以查看一或多個 HITF (主機整合追蹤檔案) 檔案。 檔案名將會TI_Tracing_ < 處理 id number > _ < date 和 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 檔案,並移除追蹤層級。 當已叫用的檔案儲存追蹤時,將會動態關閉。 不需要重新開機 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 Adapter for Host Applications 的 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 追蹤公用程式 - SNA 追蹤公用程式 可協助 TI 物件是否透過主機整合伺服器閘道使用 APPC。 此公用程式會擷取來自主機的 APPC 流量。 如果 TI 物件正透過 TCP/IP 與主機系統直接通訊,此公用程式將無法協助。