Reputation: 1048
I have an ordinary C# windows service that crawls web pages and I am experiencing a similar issue to the issue described here: An existing connection was forcibly closed by the remote host - WCF
Can I use the Service Trace Viewer Tool for an ordinary windows service (it's not wcf) or is there an alternative tracing utility I can use?
Upvotes: 0
Views: 1604
Reputation: 22251
Yes, you can add the listener by adding a system.diagnostics
configuration section to your app.config
. Add the following configuration section and point the log file to a writable path.
App.config:
<configuration>
<!-- ... -->
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Error" propagateActivity="true">
<listeners>
<add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\drop\servicename wcferror.svclog"/>
</listeners>
</source>
</sources>
<trace autoflush="true"></trace>
</system.diagnostics>
</configuration>
If you prefer to log to the event log, you can use System.Diagnostics.EventLogTraceListener
in lieu of System.Diagnostics.XmlWriterTraceListener
. The initializeData
is then the log name.
Upvotes: 4