TerminalTraceListener - A free component from Einstein Technologies

Wed, Jun 08, 2005 @ 3:32 AM - Josh Einstein

I have just decided to release “PowerTrace” a .NET assembly that contains a very cool component called “TerminalTraceListener” that allows you to quickly and easily debug your apps running in either production or staging environments.

What is PowerTrace?

PowerTrace is the name of the “product” although currently it only consists of one component. It's also free with no royalties, no license fees, no support, and no code. So it's not really a product. It is however, fully documented and extendable so you can inherit from it if you want. I just made it about an hour ago so take it for what it is.

What is TerminalTraceListener?

TerminalTraceListener is the name of the first (and currently only) component in the PowerTrace toolkit. The way it works is simple. You add the trace listener to the listeners collection either via an application configuration file or manually in code. This registers a trace listener which is a component that outputs trace information whenever you call System.Diagnostics.Trace.Write/WriteLine/etc. By wiring up listeners like this, you can output your trace information to a variety of destinations without changing your code. In fact, TerminalTraceListener will allow your application to expose a diagnostics server port without ANY changes to your code at all!

TerminalTraceListener will listen on a TCP/IP socket (you can change the addresses and ports that it will listen on, defaults to 8096, my home town's zip code) for incoming connections from any telnet client. The trace messages aren't actually sent with any telnet control codes, but any telnet client will allow you to “port into” your running application to get all of your trace messages delivered to your client in realtime.

Does TerminalTraceListener show me trace messages that happened before I connect?

Nope. Not yet anyway. Feel free to derive from it and provide that capability if you want.

Does TerminalTraceListener provide any type of security?

Nope. There is no authentication and the output is unencrypted. Again, you can derive from it and implement this functionality if you'd like but implementing encryption will probably make it pretty useless if your telnet client can't unencrypt it.

Is there any documentation?

Yes! TerminalTraceListener is fully documented (only a handful of methods and classes) and included is a CHM help file with configuration examples and the XML documentation so that VS.NET's intellisense will pick up the member descriptions.

Implementation Details and Other Stuff

The server is implemented using asynchronous sockets. It can accept as many clients as you want to connect to it and they will all receive the same output. The server will currently consume any text that you send back to it but it currently does not support any commands.

There is no installer for this component. You can stick it in the GAC or if you're like me and avoid the GAC at all times, just XCOPY deploy it with your app. There are no dependencies other than the Framework itself. The binary is currently compiled as a .NET 2.0 image but I'm going to make a 1.1 image available soon. I'm just too tired right now.

Enough already, go download the component!