Asynchronous Log4Net Appenders

I have spent the majority of my time over the last week performance profiling an enterprise application using ANTS Performance Profile. The results showed that we were having huge delays (over a second) on Log4Net when under load, which I thought was strange as it’s such a tried and tested logging framework. After some digging through their source code it’s evident that requests are processed on the calling thread, bad news for this situation! We use an AdoNetAppender so the slowdown was probably due to database contention because it’s a multi threaded architecture and the large number of requests that were being processed. I didn’t expect the loggers to use blocking calls however that’s just the way things are. Due to this I have come up with a couple of Asynchronous wrappers which run a background thread to call the base Appender and queue up the log requests in a RingBuffer which has a size limit to avoid excessive memory usage. The full production ready source code including unit tests is available on GitHub here.

Tags: , ,

About Chris Haines

.NET Software Developer based in central London. Blogging about my day to day development stumbling blocks.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: