如何生成带有详细异常信息的跟踪日志? [英] How to generate trace logs with detailed exception information?

查看:51
本文介绍了如何生成带有详细异常信息的跟踪日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi all,

我正在使用XmlWriterTraceListener编写一个svclog文件,其中包含所有需要的信息以找出所有可能问题的原因-除了堆栈跟踪和嵌套异常之类的详细异常信息.我已经知道了 轻松浏览所有异常,包括所有有用的信息,但仅将异常传递给TraceSource.TraceData不起作用:

I'm using XmlWriterTraceListener to write a svclog file containing all needed information to find out the reason for all possible problems - except of detailed exception information like stack trace and nested exceptions. I already saw how you can easily browse through all the exceptions including all that helpful information, but simply passing an exception to TraceSource.TraceData doesn't work:

_myTrace.TraceData(TraceEventType.Error, 0, exception);

这是屏幕截图服务跟踪查看器显示异常树和详细的异常信息,就像我希望的那样.

This is a screenshot of the Service Trace Viewer showing a exception tree and detailed exception information as I wanted it to look like.

感谢您的帮助,

推荐答案

Hi,

您可以阅读MSDN文档以使用TraceSource和Filters:

You can read the MSDN document to use TraceSource and Filters:

 

如何:将TraceSource和筛选器与跟踪侦听器一起使用

 

.NET Framework 2.0版中的一项新功能是增强的跟踪系统.基本前提没有改变:跟踪消息通过交换机发送到侦听器,侦听器将数据报告给关联的输出介质.主要区别 对于2.0版,跟踪可以通过 TraceSource的实例启动  class.  TraceSource 是 旨在用作增强的跟踪系统,并且可以代替较早版本的调试 跟踪 类.熟悉的跟踪调试 仍然存在,但建议的做法是使用 TraceSource 用于跟踪的类.

One of the new features in the .NET Framework version 2.0 is an enhanced tracing system. The basic premise is unchanged: tracing messages are sent through switches to listeners, which report the data to an associated output medium. A primary difference for version 2.0 is that traces can be initiated through instances of the TraceSource class. TraceSource is intended to function as an enhanced tracing system and can be used in place of the static methods of the older Trace andDebug tracing classes. The familiar Trace and Debug classes still exist, but the recommended practice is to use the TraceSource class for tracing.

文档描述了的使用TraceSource  结合了应用程序配置文件.有可能,尽管不建议这样做, 使用 TraceSource 进行跟踪而无需使用配置文件.有关在没有配置文件的情况下进行跟踪的信息,请参见如何 :创建和初始化跟踪源.

The document describes the use of a TraceSource coupled with an application configuration file. It is possible, although not recommended, to trace using a TraceSourcewithout the use of a configuration file. For information on tracing without a configuration file, see How to: Create and Initialize Trace Sources.


这篇关于如何生成带有详细异常信息的跟踪日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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