Tracing for Microsoft NET Framework-based and .NET Core client programs

Trace is activated for the IBM.CTG.Client.dll and IBM.CTG.Core.dll either by specifying it as an application configuration file or by using the Trace class.

Trace levels

The following trace levels are available:

CtgTrcDisabled
disables tracing
CtgTrcLevel1
includes exception trace points but nothing else
CtgTrcLevel2
includes event trace points and all CtgTrcLevel1 trace points
CtgTrcLevel3
includes function entry and exit trace points and all CtgTrcLevel1 and CtgTrcLevel2 trace points
CtgTrcLevel4
includes debug trace points and all CtgTrcLevel1, CtgTrcLevel2 and CtgTrcLevel3 trace points (the most verbose tracing level)

Specifying trace in an application configuration file in Microsoft .NET Framework-based applications

Trace can be enabled using the CtgTrace trace switch in an application configuration file (an XML file). The switch allows the trace to be specified as an IBM®.CTG.TraceLevel value, a System.Diagnostics.TraceLevel value, or an integer between 0 and 4 inclusive. In the following example the switch value="CtgTrcLevel4" specifies Level 4 tracing, with tracing of data blocks limited to the first 128 bytes.
<?xml version="1.0" encoding="utf-8" ?>
 <configuration>
  <system.diagnostics>
   <switches>
    <add name="CtgTrace" value="CtgTrcLevel4" dataDumpOffset="0" dataDumpLength="128"/>
   </switches>
  </system.diagnostics>
 </configuration>
<?xml version="1.0" encoding="utf-8" ?>
 <configuration>
  <system.diagnostics>
   <switches>
    <add name="CtgTrace" value="CtgTrcLevel4" dataDumpOffset="0" 
dataDumpLength="128"/>
   </switches>
  </system.diagnostics>
 </configuration>

A sample trace configuration file called App.config is included in the SDK package or in <install_path>\samples\csharp\eci and <install_path>\samples\vb\eci on a Windows machine with CICS® Transaction Gateway installed.

Specifying trace in an application configuration file in Microsoft .NET Core applications

Trace can be enabled by adding following attributes in Logging section appsettings.json file :

TraceLevel, FileName.

TraceLevel is an integer between 0 and 4 inclusive. Filename is the file where trace will be dumped. If nothing is specified, default filename is Application.trc_<PID> in current working directory of application. <PID> is appended to the trace file name(say Application.trc) to allow CICS TG to provide support for multiple processes.

In the following example, TraceLevel has been set to 4 and FileName has been set to Application.trc

.

{
    "Logging": {
    "TraceLevel": 4,
    "FileName" : "Application.trc"
    
    }
}

Using the Trace class

The Trace class includes the following members:
TraceLevel
gets or sets the trace level
DataDumpOffset
gets or sets the starting offset in each data blocks when tracing at CtgTrcLevel4
DataDumpLength
gets or sets the maximum amount of data traced in each data block at CtgTrcLevel4

For more information see Trace information in the .NET section of the Programming Reference.