views:

1067

answers:

3

Can somebody please compare these two logging mechanism?

+4  A: 

I've given some descriptions below all directly from the tool's website. I prefer ELMAH which is at the bottom, but have not spent much time on Log4Net or the Logging Application Block.

Log4Net

  • Support for multiple frameworks
  • Output to multiple logging targets
  • Hierarchical logging architecture
  • XML Configuration
  • Dynamic Configuration
  • Logging Context
  • Proven architecture
  • Modular and extensible design
  • High performance with flexibility

Logging Application Block

  • The event log
  • An e-mail message
  • A database
  • A message queue
  • A text file
  • A WMI event
  • Custom locations using application block extension points

ELMAH

  • Logging of nearly all unhandled exceptions.
  • A web page to remotely view the entire log of recoded exceptions.
  • A web page to remotely view the full details of any one logged exception.
  • In many cases, you can review the original yellow screen of death that ASP.NET generated for a given exception, even with customErrors mode turned off.
  • An e-mail notification of each error at the time it occurs.
  • An RSS feed of the last 15 errors from the log.
RSolberg
+5  A: 

This has been written about quite a bit. Here are some things to read:

http://james.newtonking.com/archive/2007/06/05/enterprise-library-logging-vs-log4net.aspx http://theiterator.com/2009/01/log4net-vs-enterprise-library-logging-application-block/ http://stackoverflow.com/questions/118047/log4net-vs-enterprise-library-which-is-better-faster

My thoughts:

  • The general consensus seems to be that log4net performs faster. Whether this is meaningful in a typical application is up for debate.
  • log4net also supports hierarchical loggers out of the box which is nice. EL can perform something similar but you have to roll your own.
  • log4net's configuration is a bit arcane and not well documented (IMO). However, EL's is also cumbersome to configure (and painful without the config tool). Also EL gives you so much choice that you may want to spend some time on design (e.g. do you want categories to be related to the logging level or layers, or functional area, or all of the previous, or something else?)

If you are already using EL, you may want to just stick with EL Logging (it also integrates with the Exception Handling Block) for consistency. If I'm using EL for an application, then I tend to use EL for logging. If not then I usually favor log4net for smaller applications since the setup time is usually shorter. (Not to impugn anyone's favorite logger! :) )

I've used both and found that they both work well.

Tuzo
great resource on log4net: http://www.beefycode.com/post/Log4Net-Tutorials-and-Resources.aspx
frankadelic
+2  A: 

This might be of interest: http://www.dotnetlogging.com/comparison/

Dennis G.