log4net vs MS Logging Application Block
Asked Answered
D

2

7

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.

Demulcent answered 12/2, 2009 at 17:48 Comment(0)
S
7

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.

Stand answered 12/2, 2009 at 18:15 Comment(3)
I have had similar problems with logging just "stopping", and its always related to a lock on the file when its trying to write.Epic
can we limit no. of emails sent for same type of error within a time span. for example there is some exception in the code and that exception is sending email, I should only get one email for every occurance of that exception in one hour (configurable)Demulcent
But what if you're logging to a database? No file lock is causing that to fail. Its infuriating; they don't write anything to the event log to help you debug failures.Stand
S
7

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)

Stylist answered 12/2, 2009 at 18:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.