thinktecture Security Token Service Starter Kit - or: "Look ma: even *I* can have a STS!"
Generating async WCF OperationContract signatures with a T4 template

Custom TraceListener writing trace messages to the .NET Services Service Bus


Dominick challenged me the other day...
For being able to better log information, warning and error messages in a truly distributed development, testing and operation environment, I built a sample custom TraceListener which leverages the Service Bus to pump tracing messages into the cloud.

Currently I am using the message-buffer-based volatile queuing mechanism in the Service Bus, but will move on to the Queue features introduced in the March 2009 bits soon.

There is a very simple ServiceContract I am using:

[ServiceContract(ConfigurationName = "Thinktecture.ServiceBusTraceListener")]
public interface IMessageTracing
{
    [OperationContract(IsOneWay = true)]
    void WriteMessage(string message);
}

All the magic is done in my custom TraceListener implementation. Here is a snippet of the relevant boilerplate code:

public class ServiceBusTraceListener : TraceListener
{
    ...
    
    public ServiceBusTraceListener()
        : base("Thinktecture.ServiceBusTraceListener")
    {
        CreateInMemoryQueue();
        SpawnWorkerThread();
    }

    ...

    public override void Write(string message)
    {
        WriteLine(message);
    }

    public override void WriteLine(string message)
    {
        traceMessagesQueue.Enqueue(message);
    }

    ...
}


This simple implementation uses a thread-safe in-memory queue data structure which is filled from within the TraceListener's WriteLine method. On 'the other side' of the queue there is a consuming thread which reads the messages from the queue (the in-memory one) and sends them to the Service Bus via a NetEventRelayBinding-enabled channel.
The background thread doing the Service Bus communication picks up all relevant WCF configuration from the config file (convention-based).

Download the sample solution.


Comments

Feed You can follow this conversation by subscribing to the comment feed for this post.

an essay

Awesome! What a cool idea. Nice work as usual guys…

essay writing services

THANX ALOT FOR THIS IT HAS HELPED ME A GREAT DEAL
KEEP IT UP

academic papers

hi
Excellent work as usual. Chill out about the updates though, we're good as long as you keep up with it...G8

an essay

that is so pretty! what a fantastic idea.

essay writing services

I really LOVE it!!!!!

Term Paper

thanks about this, this is very advantage for my study tasks,I hope this website will be survive to help the others student.
thank you……
.

Air Jordans

*Nobody can stop the wheel of history.

Inversiones en oro

I've been reading your post and I think have very good information, I would like to know the methodology you use to write your post.

vibram toe shoes

******Have you ever seen somebody lick the chutney spoon in an Indian Restaurant and put it back?
This would never have happened under the Tories.***

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Comments are moderated, and will not appear until the author has approved them.

Your Information

(Name is required. Email address will not be displayed with the comment.)