Difference between using Trace and TraceSource
Asked Answered
O

2

34

Anyone knows the difference between System.Diagnostic.Trace and System.Diagnostic.TraceSource classes?

I've been using Trace for most of my projects and I just happen to found out about TraceSource the other day. They seems to offer similar API, is one better than the other?

Oregon answered 8/7, 2009 at 23:55 Comment(0)
D
32

TraceSource is the newer version (since .NET 2) and Trace is the older version, more info is available here:

Clarification on TraceSource/Trace

Dizzy answered 9/7, 2009 at 0:1 Comment(2)
From msdn.microsoft.com/en-us/library/ms228989.aspx: "TraceSource is intended to function as an enhanced tracing system and can be used in place of the static methods of the older Trace and Debug tracing classes. The familiar Trace and Debug classes still exist, but the recommended practice is to use the TraceSource class for tracing."Allyson
This article could be very helpful too. blogs.msdn.com/b/bclteam/archive/2005/03/15/396431.aspxRident
F
10

TraceSource allows you to enhance the granularity over your tracing : in your config file you can enable/disable only the tracesource you want at the level you want (information, warning, error, ...) You can find really good explanation here : http://www.codeproject.com/Articles/149251/Debugging-Tracing-and-Instrumentation-in-NET-and-A

Floats answered 27/11, 2012 at 13:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.