2010 m. spalis 7 d., ketvirtadienis

Solving database logging bottlenecks with NLog

Solving database logging bottlenecks with NLog

Recently I worked on improving the speed of asp.net application. After several improvements the most important bottleneck was related to the database logging. We used logging extensively and Enterprise library 4 facilitated us in this.

Those of you who are familiar with Enterprise library logging capabilities probably know that they offer a great config generation tool and a script to create a database which consists of 3 tables: 

On one hand, it's convenient to use the database which is feasibly designed for the most logging needs and is automatically created.
On the other hand, there might be cases where the "solution to all problems" isn't an optimal solution. Especially if you app doesn't meet certain requirements.

In my case I choose to suggest NLog for database logging tasks instead of Enterprise library.
Suppose that we need only very primitive logging database consisting of one table:

And run a test with the following strategy:
  1. 100 one line database logs
  2. 1 is repeated 100 times and an average time is taken.

 In short, we see that performance might be improved up to 5 times. The loss is scalability and additional time for setting things up. It took me probably 7 times less time to configure Enterprise library.


  • http://msdn.microsoft.com/en-us/library/ff648951.aspx
  • http://nlog-project.org/

1 komentaras:

  1. This is even better than NLog: