-
Notifications
You must be signed in to change notification settings - Fork 202
Tracing
WARNING:
The documentation here works for .NET FX (versions .NET 4.0 - 4.8), and not for .NET Standard, .NET Core or .NET 5.0 or later as the tracing framework provided by Microsoft has changed and is no longer compatible.
The SerialPortStream object has a TraceSwitch that you can use to debug your program (or the SerialPortStream itself) if something isn't behaving as you'd expect. The name of the trace source is: IO.Ports.SerialPortStream
To enable tracing, add something similar to below in your App.Config file.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<source name="IO.Ports.SerialPortStream" switchValue="Verbose">
<listeners>
<clear/>
<add name="myListener"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="logfile.txt"/>
</sharedListeners>
</system.diagnostics>
</configuration>
You should use a switchValue of Warning or less verbosity unless you are debugging your application.
Do not trace to the console. Under the Visual Studio environment, this could bring your application to a halt. Logging to a file uses much less CPU.