Difference between using Trace and TraceSource

2019-04-03 07:31发布

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?

2条回答
我想做一个坏孩纸
2楼-- · 2019-04-03 07:56

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

查看更多
等我变得足够好
3楼-- · 2019-04-03 08:04

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

Clarification on TraceSource/Trace

查看更多
登录 后发表回答