Extending System.Diagnostics tracing APIs
The April issue of the MSDN Magazine just went on line. It contains an article I wrote that describes some advanced extensibility supported by System.Diagnostic tracing APIs. It talks about creating custom TraceListeners, Switches, and TraceSources.
Comments
- Anonymous
March 10, 2006
What happens when an exception is thrown? The trace code for leaving the function is not executed. In C++, where we have RAII, this is easily solved: put the trace call for leaving a function in the destructor of a class and have a local object of that class in every function.
What can be done in .NET? Introduce a try...finally block? Hope not.
Martin - Anonymous
March 10, 2006
If you want to ensure trace, try-finally seems to be the right choice. Why not?
But I would say that if an exception is thrown, you actually don't want the Exit event. An Enter event, optionally followed by a trace with the excetion, and the absence of the Exit event describe pretty well what actually happened. - Anonymous
March 20, 2006
I would like to extend tracing, specifically TraceEventCache to have more data (for instance, windows identity, host, etc.). How do I do this? - Anonymous
March 20, 2006
We don't currently support extending the TraceEventCache. But I think it's a good idea. I would appreciate if you could file it formally at http://lab.msdn.microsoft.com/ProductFeedback/. This way you could track the status of the request.
Thanks. - Anonymous
March 21, 2006
Check out the custom trace listener I developed. It was mentioned in MSDN magazine before by someone from Wintellect but I thought you might want to give it a look cause it's very useful.
http://josheinstein.com/journal/archive/2005/06/08/520.aspx
http://josheinstein.com/journal/archive/2005/06/09/539.aspx - Anonymous
March 21, 2006
Josh, this is a very cool idea. A twist on it would be to provide a listener that tracers to an RSS feed. You could subscribe to the feed and see, let's say, critical events in your blog reader. - Anonymous
April 21, 2006
The comment has been removed - Anonymous
April 21, 2006
Max, you are right. It should be strData.Append(data[i].ToString());
Sorry for that and thanks for catching it. - Anonymous
May 13, 2006
The comment has been removed - Anonymous
May 13, 2006
Sorry if this message is up here twice.
I am trying to run the code but I keep getting the cannot find type error for the EmailListener. I have checked the namespace and they are identical.
Any ideas or direction?
Thanks,
Che'