Barclays google robots txt search engine robots wordpress

IRC Trace Listener for .NET

I’ve hacked together a .NET custom trace listener to dump trace logs from my .NET apps into IRC.

Writing a custom trace listener is easy, just derive from System.Diagnostics.ThreadListener and implement the Write() method.

Using the listener the following code will produce the output in the screenshot:


// Trace is System.Diagnostics.Trace

Trace.WriteLine("Beggining trace test");

for (int i = 0; i < 10; i++)
{
Trace.WriteLine("Test " + i.ToString());
}

Trace.WriteLine("Trace test comlete");

IRC Trace Listener screen shot

I know, it’s awesome.

To use this, all you do is add the assemblies IrcTraceListener.dll and Sharkbite.Thresher.dll to your bin folder and register the trace listener in your app.config file as follows (you don’t have to write any code to use this).


<configuration>
<system.diagnostics>
<trace>
<listeners>
<add name="IrcTraceListener" type="IrcTraceListener.IrcTraceListener, IrcTraceListener"
initializeData="irc.hackervoice.co.uk;#test;trace" />
</listeners>
</trace>
</system.diagnostics>
</configuration>

Props to the thresher .NET IRC library, without which I would not have bothered writing this.

Download the source for IRC Trace Listener.

Posted in .NET No Comments »