log4net vs MS Logging Application Block

3k Views Asked by At

I am trying to understand pros and cons of using log4netor enterprise library logging application block (LAB) for logging in application. I know one thing LAB is little difficult to use then log4net.

2

There are 2 best solutions below

3
On

I've used Log4Net, but I didn't like it so much. Its definitely got the feel of an API translated from another language. Its been a few years, however, so it could very well have been improved since then.

I liked the configuration for LAB better, however when the LAB doesn't work, it is nearly IMPOSSIBLE to figure out WHY. Its the most aggravating thing... It can work perfectly, then seem to stop suddenly for no apparent reason. I've given up on it (last version I used was 4.1) until they figure out how to make it easy to debug.

I'd say if you're using other application blocks, stick with LAB. But be prepared to drop it after spending a week trying to debug failures to log. If you're not using another block, use Log4Net.

Also, if you're coding a web application, check out ELMAH. It's more of an error reporting module, but you can use it for rudimentary logging by manually raising events.

0
On

I use Log4Net. It is already integrated in with various other libraries I use (NHibernate) so it makes a lot of sense.

I have an Introduction to Log4Net if you want to read more. http://elegantcode.com/2007/12/07/getting-started-with-log4net/

Also, like Will said about LAB, it can be difficult to configure (done via xml config files), but Log4net is very stable. Also, you can configure Log4Net to do almost anything you want (text files, rolling text files, log to database, Event Viewer, etc)