I am learning how to use the .NET Tracing framework, and I am stuck trying to enable some fairly simple logging.
I'd like to log all messages that are at "Warning" or above to a text file, using the MyApplication.exe.config
file. I would like to enable this for all sources in the application, without having to specify them all in the config file.
In my application code I am calling System.Diagnostics.PresentationTraceSources.Refresh();
and in my .config
I have tried the following:
<configuration>
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add
name="myListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="Trace.txt" />
</listeners>
</trace>
</system.diagnostics>
</configuration>
But this does not seem to log anything.
My only success has come from explicitly listing all the sources in the .config
file; which I want to avoid as I want to catch all sources (even those I don't control).