Are there any specific uses cases where just using TraceSource will not be enough and one should consider looking into other logging libraries ( like Enterprise logging block, log4net, NLog etc)?
-
FYI, last I looked, Enterprise Library logging was based on TraceSource, TraceListener, etc. – John Saunders May 07 '11 at 19:54
-
i know that. Question is why should i use Enterprise Library logging and not TraceSource, TraceListener etc? Is there any things that i get with Enterprise Library logging and is not part of TraceSource etc? – Silverlight Student May 07 '11 at 20:03
2 Answers
The main benefit I've found to Enterprise Library logging is that it is very configurable. You can configure details for various logging categories, then change that as necessary, in Production.
For example, your standard Production configuration might be to log only error level information to the Windows Event Log (perhaps because you have some monitoring software watching the event logs). You might configure logging of warnings, or informational messages, but have those turned off by default. When necessary to see that information in Production, your Operations staff can simply enable those categories for long enough to diagnose the problem.
Another benefit is that it provides for remote logging, either by logging directly to a database, or by logging to a remote agent over an MSMQ queue. This permits logging to be centralized, at the same time as making it reliable by using the queue.

- 160,644
- 26
- 247
- 397
-
So you cannot do this type of configuration, remote logging or logging directly to dabtase with TraceSource? This link seem to suggest otherwise http://msdn.microsoft.com/en-us/library/ms733025.aspx Just to be clear, I am specifically interested in any features in entprise library logging block that cannot be done via simple TraceSource – Silverlight Student May 08 '11 at 00:24
-
No, you cannot do those things with TraceSource or any of the built-in TraceListeners. You could write your own for this purpose, but then, that's what the Enterprise Library did. – John Saunders May 08 '11 at 00:27
A few reasons to use a logging library:
1. It provides functionality or flexibility that you need and saves development effort
You may want to use Enterprise Library if you want to log to:
- WMI
- MSMQ
- Database
I believe these are not supported by the .NET TraceListeners.
In addition if you want some rolling file behavior (e.g. new file every day or after certain size etc.) then that is also supported in Enterprise Library, log4net etc. With Enterprise Library, Message format can also be set at runtime via configuration so that adds some flexibility.
2. Developers may be more familiar with a common logging library rather than a custom approach
Most projects that I've been on have used a logging library of some sort.
3. It can provide a level of abstraction over and above the built in logging functionality

- 22,566
- 4
- 68
- 94