So I have an application where I will be using tracing for logging application activity/errors etc. Most information will go in a log file whereas some errors will go in event viewer too. This application will have lots of classes.
What is the best way of using TraceSource in this case? Should I create a singleton wrapping TestSource class or is there any better way of doing it?
Best practice for using application wide TraceSource
1.3k views Asked by imak At
2
I agree to some extent with @Valdis - log4net and NLog are two examples of very powerful logging frameworks that offer a great deal of flexibility and relatively easy to use configuration (NLog is probably easier to configure than log4net). However, I don't think that is necessary to completely avoid TraceSource. TraceSource is built in so you avoid an extra dependency.
If you are using TraceSource I don't think that a single application wide static TraceSource object is the way to go. I would recommend using more TraceSources, possibly even one per class (that might be overkill, but is a common pattern when using log4net and NLog).
I have put more details in an answer to your other question about when to use more than one TraceSource in an application.