TraceSwitch和SourceSwitch-有什么区别? [英] TraceSwitch and SourceSwitch - what's the difference?

查看:35
本文介绍了TraceSwitch和SourceSwitch-有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我可能在这里缺少明显之处,但是

So I'm probably missing the obvious here, but what actually is the difference between the functionality of the TraceSwitch and SourceSwitch classes?

它们都给出了相同的摘要描述:

They both give identical summary descriptions:

提供了一个多级开关来控制跟踪和调试输出,而无需重新编译代码.

Provides a multilevel switch to control tracing and debug output without recompiling your code.

备注"部分与我的眼睛奇怪吗?有人可以说明他们在功能和使用情况上的区别吗?

Are the Remarks sections are oddly similar to my eyes. Could someone please clarify the difference in their functionality and usage cases?

(为完整起见,我将开关与我的 TraceSource 对象一起使用,而不是使用旧的静态 Trace 类,尽管我对此是否会产生很大的疑问.)

(For completeness, I'm using switches with my TraceSource object, rather than the old static Trace class, though I doubt it makes much difference.)

推荐答案

区别在于 TraceSwitch 可与 Trace 消息一起使用,而 SourceSwitch 则可使用与 TraceSource 消息一起使用,这些消息将消息与其来源相关联.因此,使用 SourceSwitch ,您可以根据跟踪消息的来源来配置侦听器.

The difference is that TraceSwitch works with Trace messages whereas SourceSwitch works with TraceSource messages, which associate the messages with their source. So with a SourceSwitch you can configure your listeners based on on where the trace messages came from.

我同意文档并没有直接指出差异,而是在相关的

I agree the documentation doesn't directly point out the difference, but dig around in the related TraceSource class documentation and you'll find this:

TraceSource 类由以下项标识来源名称,通常是应用程序的名称.痕迹来自特定消息组件可以由特定的跟踪源,允许所有来自该组件的消息容易识别.

The TraceSource class is identified by the name of a source, typically the name of the application. The trace messages coming from a particular component can be initiated by a particular trace source, allowing all messages coming from that component to be easily identified.

还有一个示例向您展示如何配置 SourceSwitch 以关闭来自跟踪源的跟踪.

There is also a sample showing you how to configure a SourceSwitch to turn off tracing from a trace source.

这篇关于TraceSwitch和SourceSwitch-有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆