.NET诊断的最佳实践? [英] .net Diagnostics best practices?

查看:202
本文介绍了.NET诊断的最佳实践?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最初并没有使用任何记录或调试跟踪,但是花费数周后追查下来,我们决定把所需的Debug.Write和跟踪生产和Debug.Assert的

We initially didn't use any logging or debug tracing but after spending few weeks to trace down some data corruption we decided to put required Debug.Write and Trace for production and Debug.Assert

所以,现在的问题是,什么是使用调试和跟踪记录的最佳做法。我只是在寻找一些东西一般。

So now question is What is the best practice to use debug and trace logging. I am just looking for some thing generic.

public void AddRectodatabase(object record)
{
   Debug.WriteLine(record.ToString());
   Trace.WriteLine(record.ToString());

   // Add it to databse

   Debug.Assert(true, "Use this on case by case basis");
}

难道这还不够好,通用,我在做什么错在那里?

Is this good enough for general purpose, am i doing anything wrong in there?

我们要坚持用.NET System.Diagnostics程序比其他的替代品像log4net的。

We want to stick with .net System.Diagnostics over other alternatives like log4net.

有没有在System.Diagnostics程序还有什么别的有用吗?

Is there any thing else useful in System.Diagnostics?

推荐答案

您应该计划提高ETW跟踪事件在您的应用程序 - 不仅提醒听众的问题,而且还提供可视性行为,甚至表现你应用程序和组件的性能。

You should plan on raising ETW trace events throughout your app - not only to alert listeners to issues, but also to provide visibility into the behavior and even performance of your apps' and components' performance.

ETW是一种(疯狂)的高性能和提高,可以收集和分析事件(惊人的)影响较小的方式 - 即使是在生产环境中。这是记录和放大器;跟踪整个基础设施中使用的Windows,SQL等。

ETW is an (insanely) high performance and (astonishingly) low-impact way of raising events that can be gathered and analyzed - even in production environments. It's the logging & tracing infrastructure used throughout Windows, SQL, etc.

为你三个有用的链接:

  1. <一个href="http://blogs.msdn.com/b/thottams/archive/2008/05/29/diagnostics-using-etw-tracing-in-net-3-5.aspx">Diagnostics:使用ETW跟踪在.NET 3.5(EventProviderTraceListener)
  2. 控制.NET框架日志链接文本
  3. 两分钟训练:介绍XPerf
  1. Diagnostics: Using ETW tracing in .NET 3.5 (EventProviderTraceListener)
  2. Controlling .NET Framework Logging link text
  3. Two Minute Drill: Introduction to XPerf

阅读全部3顺序,然后再阅读 - 后信息将是非常有用的,但会很难理解,除非你先掌握基础知识;)忽略使用logman来启动和停止跟踪收集的说明;使用XPerf代替。

Read all 3 in order and then re-read - later information will be highly useful, but will be harder to understand unless you grasp the basics first ;) Ignore the instructions to use logman to start and stop your trace collections; use XPerf instead.

如果你还没有看到<一href="http://blogs.microsoft.co.il/blogs/sasha/archive/2008/03/15/xperf-windows-performance-toolkit.aspx">the PERF工具包和XPerf观众,那么你是在为一种享受! :D

If you've not yet seen the Perf toolkit and XPerf viewer, then you're in for a treat! :D

我强烈鼓励您考虑提高启动和放大器;停止活动,在所有的应用程序最重要的特点的开始和结束,这样就可以覆盖这些事件与其他遥测,这样你可以看到,例如,您的应用程序的影响对磁盘,网络,内存,CPU特性,等等。

I strongly encourage you to consider raising start & stop events at the start and end of all of your apps' most important features so that you can overlay these events with other telemetry so that you can see, for example, the impact of your apps features on Disk, network, memory, CPU, etc.

希望这有助于。

这篇关于.NET诊断的最佳实践?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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