Question

I have various class libraries that have trace sources in them. Works fine.

In my .config file, I need to specific which source will dump it's text to the listener. Fine, works great.

But i have about 20 sources with all the same switch value and filter type, etc.

So, is there a way to say: For -all- the sources in all the libraries, use this switch value, this filter and this listener(s).

In effect: dump all trace information to this/these listener(s).

Can this be done?

Was it helpful?

Solution

You will get the largest reduction in pain using the shareListener tag: http://msdn.microsoft.com/en-us/library/ms229501.aspx

1 switch for many trace sources - no. 1 listener for many sources- yes, shared listener, I think it will still require the config to repeat (but they all point to the same shared listener). Filter-- should be able to make the filter a child element of the shared listener, so it would be defined once.

I assume you are trying to reduce the config burden, so strategies that involve custom listeners and filters would be out, but hypothetically, a custom listener and filter could be written to take as a parameter lists of trace sources-- AFAIK, no one has tried to create one. MS, I believe was hoping there would be 3rd party libraries that extend System.Diagnostics, at the moment UKADC and Essential.Diagnostics are the best, and I'd use their base classes for extending what MS already provided.

And another possibility is to register the listeners programmatically in code, which avoid the config altogether and provides the opportunity to use loops.

I dealt with this by creating a code generating app that generated a system.diagnostics section-- the generating code was simple to read, the resulting config was large and verbose and repetitive.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top