Any there any good libraries out there that extend System.Diagnostics.Trace?
Some of the features I am looking for.
- Rolling logs
- smtp
And “Use log4net” is not an answer. The reason being is that i don’t want a reference to any third party assemblies.
In response to comments:
Because using trace does not pollute the business code. I only call Trace.XXX. Using an extension to Trace can be done in config or a small amount of code at startup. If I use log4net is need references to it everywhere.
I understand why you don’t want to pollute your business code with a dependency on a third party API.
However it is also a fact that System.Diagnostics.Trace is not as flexible an API as that provided by other logging frameworks like EntLib and Log4Net.
What I’ve done is developed an internal API that is strongly influenced by log4net, that uses a provider-model design pattern to provide a thin wrapper over any suitable logging framework. I have providers for System.Diagnostics.Trace, log4net and EntLib. The basic concept is very similar to The Common Infrastructure for .NET logging library.
In this way your business code only has a dependency on your own internal API, and the logging framework can be selected at runtime using configuration.
Of course you can achieve what you want by sticking to System.Diagnostics.Trace and writing your own TraceListeners for SMTP (See this CodeProject sample) or rolling logs. Or write your own TraceListener that redirects to a logging framework such as Log4Net, which then gives you access to the loggers supported by that framework.