tags:

views:

553

answers:

8

Hi, I'm looking into how to implement logging in my C# app - its a DLL class library. What logging frameworks are most widely used - what would give users of my DLL the most flexibility and configurability? Is there a C# equivalent of log4j?

+13  A: 

Equivalent of log4j for .NET platform is log4net and I am guessing it's widely used.

Cagdas Altinkaya
I use log4net in nearly all my .NET applications. However, my classes do not hold a reference to log4net directly, I hide this infrastructure concern behind an interface and use dependency injection.
JohnRudolfLewis
We're also using log4net. It is just great. Incredibly flexible, incredibly fast.
Stefan Steinegger
use log4net and never look back... Doesnt SO use log4net?
Allen
+2  A: 

Have used NLog successfully in numerous projects.

ozczecho
+1  A: 

Here´s a similar question about Logging-Framework for .NET 3.5 What is the best logging solution for a C# .NET 3.5 project.

Jehof
A: 

I am using NLog from years with success and it is very well done project.

twk
+1  A: 

We use our own logging classes, implemented by calling log4net. This allows us to take advantage of this flexible and widely-used framework while avoiding thousands of direct references to it in the source code.

azheglov
A: 

People have been using Enterprise Library extensively. But it may be true that developers are switching to other products these days.

I'd check it out and see if it has the necessary functionality you need and not too much bloat.

Robert Koritnik
A: 

Enterprise Library. It's robust and comes straight from Microsoft with all their best practices included. We use it in all our projects. It's very flexible and there is a UI tool that you can use in case you don't want to mess around with managing logging from the config file.

desigeek
+1  A: 

log4net is almost certainly the most common.

But I use Common.Logging - http://netcommon.sourceforge.net/ as it gives me flexibility

There are a variety of logging implementations for .NET currently in use, log4net, Enterprise Library Logging, NLog, to name the most popular. The downside of having differerent implementation is that they do not share a common interface and therefore impose a particular logging implementation on the users of your library.

Common.Logging library introduces a simple abstraction to allow you to select a specific logging implementation at runtime. Thus you can defer the decision what particular logging library to use until deployment. Adapters are used for plugging a particular logging system into Common.Logging.

gef