The MSDN documentation for the TraceSource class has an example of how the app.config file can list out information for TraceSource instances:
http://msdn.microsoft.com/en-us/library/system.diagnostics.tracesource.aspx
However, there is no information on where the TraceSource values are stored...where are the existing TraceSource objects stored? When are they (edit: they means configured instances) constructed? How does the TraceSource object know how to return a named instance (edit: should be configured instance) instead of a new instance when creating a TraceSource object? Can I find a list of existing TraceSource objects without using Reflection?
The TraceSource class keeps a private List of sources. But that isn't accessible by anyone but the TraceSource class itself.
The .config file section is meant to configure the listeners for a trace source. So when you create a TraceSource in your code, it uses the name you passed in the constructor and goes looking in the .config file to see what listeners should be added or removed automatically.
So code creates the a source, the .config file configures it. Not the other way around, a .config file cannot create a source.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With