Search code examples
c#loggingenterprise-library

Compare Logging Application Block in Enterprise Library versus Log4net?


Can somebody please compare these two logging mechanism?


Solution

  • 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/ https://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.