TcpTraceListener, Finally!

An entry about tools Publication date 27. May 2007 13:55

Ok, so in my previous post I promised to have this up in a few days - and that was over two weeks ago :p Those two weeks became a rat race to finish a beta version of the web portal we're developing at work, as it was schedule for a big demonstration a few days ago. Well we got it (mostly) done, and we managed to demo it withouth any major hickups. So now that that's in the past, I've got my life back and will hopefully be able to continue blogging regularly :) Without any further ado then, here is the source code for the TcpTraceListener and client that goes with it, as promised:

Download the TcpTraceListener project.

Using the TcpTraceListener is quite easy: All you need to do is include the TcpTraceListener.dll with your application, and add the following lines to the app/web configuration file:

  <system.diagnostics>
<trace autoflush="true">
<listeners>
<add name="TcpTraceListener" 
type="TcpTraceListener.TcpTraceListener, TcpTraceListener" 
initializeData="127.0.0.1:9595" />
</listeners>
</trace>
</system.diagnostics>

You can leave the initializeData attribute blank, in which case it will default to localhost on port 9595.

Fire up your application, and any trace messages will now be sent to any TcpTraceListenerClient apps you've connected. For example:

Trace.WriteLine("Info: Application started.");

Notice the keyword at the beginning of the trace message, which the client will use to color-code the message in the log window. You can customize the keywords by changing the settings in the client. The default ones are "Info:", "Warning:" and "Error:".

Be warned that I consider the project to be a beta, and I've got a few things I'd like to improve on it. So use it at your own risk :)

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Powered by BlogEngine.NET 1.4.5.0

Welcome!

My name is Fredrik Kalseth, and this is my blog - thanks for visiting! I am fortunate enough to work with what I love for a living, and this blog is essentially the biproduct of that.

I work as a senior consultant for Capgemini, and am also an active participant in the Norwegian .NET community, as an avid attendee but also as a speaker (most recently at NNUG and MSDN Live).

As a developer, I have a wide circle of interest. My primary passion is for agile, test-driven development, with focus on best practices and clean code. That said, I also love to work on the frontend, especially with web development.

On Twitter? My handle is fkalseth. On LinkedIn? I`m there too.


Disclaimer

This is a personal blog; any opinions expressed here are my own and do not necessarily reflect those of my employer. All content herein is my own original creation, and as such is protected by copyright law. Unless otherwise stated, all source code posted on this blog is freely usable under the Microsoft Permissive License.

What Readers Talk About

Comment RSS