C# Enterprise Library Asynchronous Logging


We all know how slow any logging mechanism is, specially when one of the trace listeners is logging to a database. By using .NET 4.0 with it’s Parallel Library (System.Threading.Task) we can easily turn our logger to use fire-forget asynchronous operation.

 Example below uses Enterprise Library 5.0.

Suppose this is your existing LogMessage method:

Just add another method LogMessageAsync with ff code:

Now to log asynchronously just call the LogMessageAsync() method.

 

 

Advertisements

2 thoughts on “C# Enterprise Library Asynchronous Logging

  1. Pingback: Enterprise Library Logging and Task Parallel Library – Writing to the log from a separate thread?

  2. Hi, I do think this is a great web site. I stumbledupon it 😉 I
    may return yet again since I bookmarked it.
    Money and freedom is the greatest way to change, may you
    be rich and continue to guide others.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s