What is the difference between log4net and ELMAH?

IAdapter picture IAdapter · Feb 20, 2011 · Viewed 38.1k times · Source

Some people are using ELMAH instead of log4net. What makes it better?

I found out about ELMAH in an answer to Stack Overflow question How do I do logging in C#?

Answer

Mike Valenty picture Mike Valenty · Feb 20, 2011

Log4Net is a general purpose logging framework with an API intended to be used within your application (web, console, dll, etc.).

logger.Debug("Some low level debug message...");
logger.Info("Some basic info");
logger.Warn("Some business logic problem, but not critical");
logger.Error("An unexpected error");

ELMAH is an unobtrusive IIS plugin specifically for logging exceptions in a web application. You won't see a reference to ELMAH within your application, it doesn't have an API that you interact with. It uses the module and handler IIS extension points to bolt in the behavior. In addition it has a web front-end to view the errors that have occurred in your web application. Log4Net doesn't have a front-end, just a variety of log sinks (Appenders) that can send your log messages to things like log files, a syslog server, a database, etc.