log4net and the Logging classes inside the framework

The main motive behind using either of the logging framework (log4net or logging classes in .net) depends on the complexity of the application you are developing. The Logging classes of .NET works best if you are developing a simple application. But as the application grows (with features like multithreading, remoting ..) then you lack some of the functionality that you wished to be there in the framework. This is the point where you try to develop extensions to the standard framework. But in some scenarios you find yourself facing a dead end. So then you go for creating your own in-house version of the logging framework. Even if you do know about some existing opensource effort, you would ignore it because you heard of many horror stories about lack of support and documentation provided with free OpenSource software. I can tell you that log4net is not one of such frameworks. It comes with a very descriptive sdk documentation and a lot of samples in both c# and vb.net. Also the developer's mailing list is very active and responsive for any of your problems. It also has support for .net framework 1.0 /1.1, mono, sscli and rotor.  Below are some of the points for each framework in my personal opinion.
 
log4net:
+ The framework provides you implicit support to track the context of the class instance you are logging in.
+ Number of useful Logging Listeners (Appenders as they call it in log4net) included with the framework so that you dont have to reinvent the wheel. Some of them are Console, Databases, Events, Remoting Sink, Files etc.
+ Implicit support for tracking context in multithreaded applications.
 
.NET Framework support for Logging:
+ provided in the standard framework library.
 
Oh..Why am I writing this? Actually I wrote an article about using log4net and you know that the first thing that covers everything is the daily grind from larkware :-) Mike also asked about the need of a separate framework for logging if there is support provided inside the framework. This post covers some of the reasons.
 
BTW, I am also looking forward to hear your experiences with log4net or the logging classes inside the .net framework.

1 Comment

  • First Thanks for writing this article this really helped me choosing logging framework.

    Infact you have written exactly right that Log4Net is performance booster than C# logging.



    I checked it and found that on a P4 System log4net is logging "Entering Application" to a file with 125000 logs/sec and c# give 42000 logs/sec with the same configuration...

    These are observations and may differ with others..



    Best Regard...

    SHERRY

Comments have been disabled for this content.