Difference between revisions of "QuickOPC: How to enable extended tracing"

From OPC Labs Knowledge Base
Jump to navigation Jump to search
m
Line 1: Line 1:
 
[[Category:How to]] [[Category:Instrumentation]] [[Category:OPC Classic]] [[Category:OPC UA]] [[Category:Troubleshooting]]
 
[[Category:How to]] [[Category:Instrumentation]] [[Category:OPC Classic]] [[Category:OPC UA]] [[Category:Troubleshooting]]
This information applies to version 2021.1 or newer. [[#Earlier versions|Earlier versions]]
+
This information applies to version 2021.1 or newer. -> [[#Earlier versions|Earlier versions]]
 
= Enabling the extended tracing =
 
= Enabling the extended tracing =
 
For advanced troubleshooting, it is sometimes necessary to obtain information about QuickOPC internal status and activities. This can be done by enabling extended tracing, as described in this application note. Most of the tracing is for OPC UA, but there is some tracing for other OPC specifications as well.
 
For advanced troubleshooting, it is sometimes necessary to obtain information about QuickOPC internal status and activities. This can be done by enabling extended tracing, as described in this application note. Most of the tracing is for OPC UA, but there is some tracing for other OPC specifications as well.

Revision as of 10:21, 11 January 2021

This information applies to version 2021.1 or newer. -> Earlier versions

Enabling the extended tracing

For advanced troubleshooting, it is sometimes necessary to obtain information about QuickOPC internal status and activities. This can be done by enabling extended tracing, as described in this application note. Most of the tracing is for OPC UA, but there is some tracing for other OPC specifications as well.

The logging is enabled by various .NET trace switches, and settings in configuration file sections. Unless you are able to observe the output in the debugger or using a special tool, you also need to direct the trace to a proper listener, using the standard means provided by .NET tracing facility. It is up to you how you enable the switches or configure the listener(s). Typically, it is done using the application configuration file, with the advantage that it can be done without rebuilding the application.

The example below shows the application configuration file with common parts of the extended tracing enabled.

 1 <?xml version="1.0"?>
 2 <configuration>
 3   <configSections>
 4     <section
 5       name="OpcLabs.EasyOpc.UA.Toolkit.SdkTrace"
 6       type="OpcLabs.EasyOpc.UA.Toolkit.SdkTraceSection,OpcLabs.EasyOpcUA" />
 7   </configSections>
 8   <OpcLabs.EasyOpc.UA.Toolkit.SdkTrace traceOutput="3" >
 9   </OpcLabs.EasyOpc.UA.Toolkit.SdkTrace>
10   <startup>
11     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
12   </startup>
13   <system.diagnostics>
14     <switches>
15      <!-- Source switches -->
16      <add name="EasyUAClientEngineBase" value="Verbose" />
17      <add name="NetSdkEasyUAClient" value="Verbose" />
18      <add name="NetSdkEasyUASubscriber" value="Verbose" />
19      <add name="OpcLabs.Boxing.Applications" value="Verbose" />
20      <add name="OpcLabs.Boxing.Progress" value="Verbose" />
21      <add name="OpcLabs.Configuration.Retrieve" value="Verbose" />
22      <add name="OpcLabs.EventTracing.LogEntries" value="Verbose" />
23      <add name="OpcLabs.EventTracing.SafeCritical" value="Verbose" />
24      <add name="OpcLabs.Reflection.AssemblyLoading" value="Verbose" />
25      <add name="UAEngineBase" value="Verbose" />
26      <add name="UASmartClientEngine" value="Verbose" />
27 
28       <!-- Other switches -->
29      <add name="OpcLabs.CallDiagnostics.Display.CallPort" value="1" />
30      <add name="OpcLabs.CallDiagnostics.Display.Enabled" value="1" />
31      <add name="OpcLabs.CallDiagnostics.Display.EnterPort" value="1" />
32      <add name="OpcLabs.CallDiagnostics.Display.ExitPort" value="1" />
33      <add name="OpcLabs.CallDiagnostics.Display.LeavePort" value="1" />
34      <add name="OpcLabs.CallDiagnostics.Display.TickCount" value="1" />
35      <add name="OpcLabs.EasyOpc.UA.Toolkit.Sdk.DisplayCalls" value="1" />
36      <add name="OpcLabs.EasyOpc.UA.Toolkit.SdkCallback.DisplayCalls" value="1" />
37      <add name="OpcLabs.EasyOpc.UA.Toolkit.SdkEnvironment.DisplayCalls" value="1" />
38      <add name="OpcLabs.EasyOpc.UA.Toolkit.SdkMethod.DisplayCalls" value="1" />
39      <add name="OpcLabs.EasyOpc.UA.Toolkit.SdkTarget.DisplayCalls" value="1" />
40     </switches>
41   </system.diagnostics>
42 </configuration>

The relevant parts of the file are highlighted. Specifically, following information will be contained in the traces:

  • All trace information from inside OPC UA .NET Stack and SDK.
  • Calls to and from OPC UA .NET Stack and SDK.
  • Log entries generated by the component.

Please refer to Microsoft documentation for details on the application configuration files, the diagnostic switches, the trace listeners, and so on. The application configuration file needs to be named the same as your application, with an added “.config” extension, and placed alongside the application. For example, for “MyApp.exe”, the configuration file is “MyApp.exe.config”. Note that the development tools sometimes provide “shortcuts” for the naming and placing procedure. For example, Visual Studio C# projects contain an app.config file, which becomes the application configuration file automatically – Visual Studio copies it to the output folder and renames it appropriately.

Note2-icon.png

Note: Under COM platform, QuickOPC objects get loaded into the process of the application that creates and calls them. You therefore need to create or modify the configuration file for the application itself (as if it were a .NET application). In hosted environments, such as ASP.NET, the name and location of the configuration file may be different as well.

By default, the traces are directed to the Windows debug output, which you can observe e.g. when you run the program under a debugger, or it can be viewed and captured using specialized tools such Sysinternals’ DebugView (http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx ).

Trace Switches

Following table lists some selected trace switches and their meaning.

Name Description Type Default value
OpcLabs.EasyOpcClassicRaw.OCKClient.BrowseNodes Browsing for OPC DA nodes. BooleanSwitch 0[1]
OpcLabs.Licensing.Invoke License invocation. BooleanSwitch Critical[2]
OpcLabs.Licensing.Verify License verification. BooleanSwitch Critical[2]

Switches in Debug configurations

The switches listed here are only functional in Debug configurations. Note that Debug configurations of the software are not normally made available to customers.

Name Description Type Default value
DotPrologEngine.DebugTracingDebugger Tracing debugger. BooleanSwitch 0

Trace Listener Configuration

If you do not want to use the default debug trace configuration (directing the traces to the debug output), you can configure the trace listener(s) in various ways. Please refer to Microsoft documentation for details.

In the configuration snippet below, we have included shared listener definitions for various types of listeners provided by Microsoft (you can remove or comment out the ones that you do not need). With the shared listeners definitions, you can then configure every trace source simply by adding a (shared) listener to it, using the listener name. For example, to store the output into a comma-delimited file “TraceOutput-DelimitedList.csv” (in the same folder as the application), use the following configuration part:

 1   <system.diagnostics>
 2     <sharedListeners>
 3       <!-- Console -->
 4       <add name="Console" type="System.Diagnostics.ConsoleTraceListener" />
 5 
 6       <!-- DelimitedList -->
 7       <add name="DelimitedList"
 8            type="System.Diagnostics.DelimitedListTraceListener"
 9            traceOutputOptions="DateTime, ProcessId, ThreadId"
10            initializeData="TraceOutput-DelimitedList.csv" 
11            delimiter="," />
12 
13       <!-- EventLog -->
14       <add name="EventLog"
15            type="System.Diagnostics.EventLogTraceListener"
16            initializeData="TraceListenerLog" />
17 
18       <!-- EventSchema -->
19       <add name="EventSchema"
20            type="System.Diagnostics.EventSchemaTraceListener, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
21            traceOutputOptions="ProcessId, DateTime, Timestamp"
22            initializeData="TraceOutput-EventSchema.xml"
23            bufferSize="65536"
24            logRetentionOption="LimitedCircularFiles"
25            maximumFileSize="20480000"
26            maximumNumberOfFiles="2" />
27 
28       <!-- FileLog -->
29       <add name="FileLog"
30            type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
31            initializeData="FileLogWriter" 
32            baseFileName="TraceOutput-FileLog"
33            location="ExecutableDirectory" />
34 
35       <!-- TextWriter -->
36       <add name="TextWriter"
37            type="System.Diagnostics.TextWriterTraceListener"
38            initializeData="TraceOutput-TextWriter.txt" />
39 
40       <!-- Xml -->
41       <add name="Xml"
42            type="System.Diagnostics.XmlWriterTraceListener"
43            traceOutputOptions="ProcessId, DateTime" 
44            initializeData="TraceOutput-Xml.xml" />
45     </sharedListeners>
46 
47     <trace autoflush="true" indentsize="4">
48       <listeners>
49         <add name="DelimitedList" />
50         <remove name="Default" />
51       </listeners>
52     </trace>
53 
54     <sources>
55       <source name="EasyUAClientEngineBase"> <listeners> <add name="DelimitedList"/> <remove name="Default"/> </listeners> </source>
56       <source name="NetSdkEasyUAClient"> <listeners> <add name="DelimitedList"/> <remove name="Default"/> </listeners> </source>
57       <source name="NetSdkEasyUASubscriber"> <listeners> <add name="DelimitedList"/> <remove name="Default"/> </listeners> </source>
58       <source name="OpcLabs.Boxing.Applications"> <listeners> <add name="DelimitedList"/> <remove name="Default"/> </listeners> </source>
59       <source name="OpcLabs.Boxing.Progress"> <listeners> <add name="DelimitedList"/> <remove name="Default"/> </listeners> </source>
60       <source name="OpcLabs.Configuration.Retrieve"> <listeners> <add name="DelimitedList"/> <remove name="Default"/> </listeners> </source>
61       <source name="OpcLabs.EventTracing.LogEntries"> <listeners> <add name="DelimitedList"/> <remove name="Default"/> </listeners> </source>
62       <source name="OpcLabs.EventTracing.SafeCritical"> <listeners> <add name="DelimitedList"/> <remove name="Default"/> </listeners> </source>
63       <source name="OpcLabs.Licensing.Invoke"> <listeners> <add name="DelimitedList"/> <remove name="Default"/> </listeners> </source>
64       <source name="OpcLabs.Licensing.Verify"> <listeners> <add name="DelimitedList"/> <remove name="Default"/> </listeners> </source>
65       <source name="OpcLabs.Reflection.AssemblyLoading"> <listeners> <add name="DelimitedList"/> <remove name="Default"/> </listeners> </source>
66       <source name="UASmartClientEngine"> <listeners> <add name="DelimitedList"/> <remove name="Default"/> </listeners> </source>
67       <source name="UAEngineBase"> <listeners> <add name="DelimitedList"/> <remove name="Default"/> </listeners> </source>
68     </sources>
69 
70   </system.diagnostics>

Earlier versions


  1. Default value is 1 in Debug configurations
  2. 2.0 2.1 Default value is Verbose in Debug configurations