Enterprise Logging Block vs NLog vs log4net

24,983

Solution 1

I personally like log4net. It's fast, stable and configurable (and it's really easy to extend with a custom appender or such).

I am not bothered by the lack of new releases - in my mind it just proves that the code base is stable and contains the features it should. After all, I want my logging to be stable above all.

Here is a slightly similar question, perhaps you can also use some of the answers from there.

Solution 2

I just evaluated log4net and NLog for usage in a bigger project. Both have a similar interface and are highly configurable.

NLog seems to be better maintained: An incompatibility of log4net with .Net4 remained unresolved in log4net for quite a long time. Nlog comes with some more 'bells and whistles' like a NuGet Package and a Xml Schema for Visual Studio for editing config files.

In the end we decided for log4net because we measured a much better performance for log4net: A simple test, writing 10000 log messages to a file and to a network log viewer (Log2Console) showed a ten times better performance of log4net! We did no tuning in the config file, file and notwork logger were used with a minimal configuration. You should verify this for yourself with a typical logging setup of your project.

Solution 3

You can postpone the decision "which logger to use" if you are using Common.Logging . This is a logging wrapper where you can configure wether logging should go to log4net, nlog, System.Diagnostics.Debug. I donot know Enterprise Logging Block and i donot know if there is a "Enterprise Logging Block" plugin for common logging.

Solution 4

Another difference that's often overlooked is that NLog is BSD while log4net is under Apache license. ELB is MS-PL (microsoft's open source version). That might not matter in most cases, just saying.

Solution 5

I find them all to be quite similar and capable. It's been several years since I used the Enterprise Library Logging Block, but even back then it was decent. NLog & log4net are both solid.

One reason to choose one over another may be 3rd party library integration. If you are using NHibernate or Quartz or other libraries that utilize log4net, for example, it may drive your choice.

Share:
24,983

Related videos on Youtube

imak
Author by

imak

Always consider myself as a student who is open to learn new things

Updated on July 09, 2022

Comments

  • imak
    imak almost 2 years

    I need to use a logging library in my project and considering between Enterprise Logging Block vs NLog vs log4net. I found some links on the comparison but most of those are quite old and complaint about things like no new versions of log4net for long etc.

    Anyone has suggestion regarding which one is better in terms of ease of use, ease of configuration, performance, scalability etc based on current data.

  • W.Gross
    W.Gross about 12 years
    Just had a look with the profiler: It seems that the problem lies in the default setup of the loggers. log4net keeps the logfile open be default, NLog doesn't. if you configure NLog appropriately, it shows the same performance as log4net.
  • Nick
    Nick about 10 years
    what exactly is the difference between BSD license and Apache license ? i think i encountered this difference in Thrift and Zeroc licenses too .
  • nawfal
    nawfal about 10 years
    They both are pretty similar permissive licenses with Apache being more detailed (and hence complex) and restrictive. I dont understand much, but one major difference is that with Apache license you are required to explicitly state the changes you make to the code.
  • Rosdi Kasim
    Rosdi Kasim about 9 years
    That link is not updated. You should link to github.com/net-commons/common-logging instead,
  • k3b
    k3b about 9 years
    @Rosidi thanks for info. I have updated the link from netcommon.sourceforge.net to github.com/net-commons/common-logging
  • Scott Simontis
    Scott Simontis about 9 years
    This guy wrote that there were a lot of bugs in Log4Net and that it was failing a lot of its own test suites. The situation may have improved, but I would hesitate to call it stable based upon issues like below with the amount of time it took for a .NET4 compatible release.
  • Scott Simontis
    Scott Simontis about 9 years
    I would love to see a detailed analysis of logger performance, most discussion I have seen seems to revolve around a limited number of personal test cases. I have heard a lot of people say that NLog was considerably faster for them compared to Log4Net, but none of them offered numbers. Regardless, they are both faster than EntLib logging :)
  • VikciaR
    VikciaR almost 9 years
    @Scott: it is very old post. Now log4net is in development again, for example current version is from 2015-03. So, this isn't correct argument.

Related