log4net Comparison

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

log4net Comparison

plinyar
Hi, coleagues. Can anybody let me understand what are the benefits of using NLog over log4net. A short look at architecture and feature couldn't give me any sensible difference.
Please....
Reply | Threaded
Open this post in threaded view
|

Re: log4net Comparison

Jarek Kowalski
Administrator
The basic difference is that NLog uses log routing table while log4net uses logger hierarchy with attachable appenders and filters. This implicates a different approach to configuration. It's up to the user to decide which approach is better. In general, NLog lets you write more sophisticated logging configuration with less XML configuration code:

NLog has:

* no object renderers (I believe this is needed in Java, not in .NET)
* no custom layouts (only layout-renderer based)
* no custom loglevels (you get some sort of standarization and library interoperability)
* no cross-thread-serializable logeventinfo - I believe this isn't needed
* no plugins (actually the architecture is very pluggable, but not this way)
* no logging repositories (there's only one, which brings less confusion)
* no need to use any configuration assembly-level attributes (NLog uses auto-configuration)
* no need to remember class names for targets, filters and layout renderers (uses "File" instead of "log4net.Appender.FileAppender")
* very simple and readable configuration schema
* only two configuration languages to memorize: xml configuration language and layout renderer sublanguage ${message:uppercase=true}
* less abstraction at the logger interface (log4net.ILog is an abstract interface while NLog.Logger is a concrete, highly optimized class which improves non-logging speed down to 8 nanoseconds per non-logging call (on my Centrino 1.6 GHz laptop)
* support for many common overloads in the logger API (to eliminate memory garbage wherever possible)
* a File target which is multiprocess-safe by default
* mixed-mode API for C/C++ and COM Interop API
* asynchronous targets (write to file, network in a separate thread - available in Subversion, not in the 0.9 release)
* one binary distribution that works for Mono 1.x, .NET 1.0, .NET 1.1 and .NET 2.0
* support for ASP and ASP.NET layout renderers
NLog Blog