Showing posts with label c# programming Microsoft Enterprise Logging Application Block Log4Net Logging. Show all posts
Showing posts with label c# programming Microsoft Enterprise Logging Application Block Log4Net Logging. Show all posts

Wednesday, April 2, 2008

Is Enterprise Logging Application Block the best choice for Logging?

I've been using Log4Net for quite some time now, but I recently came across a new logging framework called Microsoft's Enterprise Logging Application Block. That is quite a mouthful, but it sounds promising. The Logging Application Block is part of a collection of other application blocks that is called the Enterprise Library. The Enterprise Library contains eight application blocks:

  • Caching
  • Cryptography
  • Data Access
  • Exception Handling
  • Logging
  • Policy Injection
  • Security
  • Validation

Let's see how the Logging Application Block compares to Log4Net. For this review we will use Microsoft Enterprise Library 3.1 - May 2007 and Log4Net 1.2.10. The four areas we will compare them on are easy of use, configuration, performance, flexibility.

Easy of Use

Setup of Enterprise Logging for flat files and the event log is very easy with the help of the Enterprise Library Configuration utility. Logging to the database was a little more difficult and a little awkward. For instance you need to set the Formatter for the Database Trace Listener even though it doesn't dictate what is entered into the database.

Log4Net doesn't have a UI configuration, but I've always found the setup is documented well and intuitive to implement.

Configuration

The Enterprise Logging application block can be configured using the Enterprise Library Configuration utility. Both Log4Net and Enterprise Logging modify the XML config file, so manual configuration can be done easily. Both of them also support programmatic configuration as well.

Both loggers include logging to text files, databases, event log and email. Log4Net includes logging to the console with colored ANSI for enhanced readability.

Performance

My initial tests showed Log4Net being exponentially faster. Others have found this to be true as well. For more details and stats check out Loren Halvorson's Blog.

Flexibility

The Enterprise Logging provides full source code. And has an extensible trace listeners. Log4Net's Appenders offer similar functionality.

In summary the Enterprise Logging Application Block is a very full featured and extensible logging framework. If you are using any of the other Enterprise Application Blocks this would be the first logger to try. It's only downfall is that it's performance is lacking. Unlike Log4Net the Enterprise Library including the Logging Application Block is being updated quite regularly.

If you would like to try one of these logging frameworks out check out these tutorials:
Some other Logging Frameworks:

Save to del.icio.us Add to Technorati Add to dzone