What is the difference between log4net and ELMAH?
Solution 1:
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.
Solution 2:
ELMAH serves a purpose of tracking errors and exceptions for your web applications and allows you to easily log or view those exceptions via many different mechanisms (SQL, RSS, Twitter, files, email, etc.). If you have no built-in exception handling ELMAH will most likely get you what you are looking for in terms of exception handling in a web application environment.
Log4net can be used for exception logging as well, however you might need to roll your own handlers to plug into your web application. Log4net will shine over ELMAH if you need to do other types of information logging as log4net is a general purpose logging framework. Log4net can also be used in almost any .NET application.
Solution 3:
The key difference is that ELMAH logs unhandled application exceptions; log4net logs whatever you tell it to log. You can configure log4net to log unhandled exceptions, but ELMAH captures a wealth of useful information out of the box.