In this post I will talk about setting up a trace for the WCF-Adapter. This post should be a good addition to some previous posts I made about the WCF-Adapter.
Communicating with SAP through WCF : Send and Receive Ports
Communicating with SAP through WCF : Generate SAP schemas
1. Tracing within the Adapter
Add the following to the configuration section of your BizTalk configuration file, BTSNTvc.exe.config which is present under <system drive>:\Program Files\Microsoft BizTalk Server 2006:
<source name="Microsoft.ServiceModel.Channels" switchValue="Warning">
<add name="eventlog" />
<source name="Microsoft.Adapters.SAP" switchValue="Warning">
<add name="eventlog" />
<add name="eventlog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/>
<trace autoflush="false" />
This will enable Warning level tracing (Errors + Warnings). Replace APPLICATION_NAME with the name of your application as you want it to appear in the event viewer. Now you can see the errors and warnings - even the ones that were thrown to SAP.
If not possible to write to event log or if too bulky, then alternatively, you can put the following instead of the listeners “event log” if you want to log to a file. You will then need the tracing viewer (see below):
<add name="xml" type="System.Diagnostics.XmlWriterTraceListener"
ATTENTION: Trace files can become huge. Remember to stop tracing once issues have been solved.
2. Tracing the Adapter and the LOB Application
To diagnose issues that you suspect are related to the LOB application, you must enable tracing for communication between the adapter and the LOB application. Adapters also depend on LOB tracing (client/server side) to access this information. The SAP adapter enables adapter clients to turn on tracing within the SAP system by specifying the "RfcSdkTrace" parameter in the connection URI. You must specify this parameter to enable the RFC SDK to trace information flow within the SAP system. For more information about the connection URI, see The SAP System Connection URI.
This parameter is specified in the SAP binding URI of the BizTalk WCF adapter:
Additionally, you can also create an RFC_TRACE environment variable that sets the level of tracing for the RFC SDK. RFC_TRACE is an environment variable defined by SAP and is used by the RFC SDK. If this variable is not defined or is set to 0, the RFC SDK tracing level is bare minimum. If the variable is set to 1 or 2, the tracing level is more detailed.
RFC_TRACE = 2
RFC_TRACE_DIR = C:\log\LOB
Note: Irrespective of whether the RFC_TRACE environment variable is set, the RFC SDK tracing is enabled only if setting the "RfcSdkTrace" parameter to true in the connection URI (see in STEP 2). The value of this environment variable solely governs the level of RFC SDK tracing. If RfcSdkTrace is set to true, the message traces between the adapter and the SAP system are copied to the “system32” folder on your computer. To save the RFC SDK traces to some other location, you can set the RFC_TRACE_DIR environment variable. For more information about these environment variables refer to the SAP documentation.
3. Viewing the Traces
You can use the Windows Communication Foundation (WCF) Service Trace Viewer tool to view the traces. For more information about the tool, see "Using Service Trace Viewer for Viewing Correlated Traces and Troubles" at http://go.microsoft.com/fwlink/?LinkId=91243 .