Console.writeline()/trace.writeline()之间的区别 [英] Difference between Console.writeline() /trace.writeline()

查看:197
本文介绍了Console.writeline()/trace.writeline()之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Console.WriteLine() Trace.WriteLine()有什么区别?

推荐答案

调试角度查看这些内容。

Look at these from the "Debugging" perspective.


  • 我们开始使用 Console.WriteLine()
  • $ b进行调试$ b
  • 后来我们知道总是在控制台上打印调试数据可能不好。我们甚至可能没有控制台。然后我们开始使用 Debug.WriteLine(),它将在Visual Studio输出窗口上打印我的调试信息。

  • 然后我们知道了我们不应该在发布模式下打印所有调试信息,因此我们应该在发布模式下使用 Trace.WriteLine()。在调试模式下,我们可以看到 Debug.WriteLine() Trace.WriteLine()的输出。

  • 这里是一个很好的参考:跟踪和调试的使用

  • We started debugging using Console.WriteLine()
  • Later we got to know it might not be good to print debugging data on console always. We might not even have a console. Then we started using Debug.WriteLine(), which prints my debug information on Visual Studio output window.
  • Then we got to know that we shouldn't print all debug information in release mode, so we should use Trace.WriteLine() in release mode. In debug mode we can see outputs from both Debug.WriteLine() and Trace.WriteLine().
  • Here's a very good reference: Usage of Trace and Debug

在同一应用程序中分别使用 Trace Debug 类。在调试解决方案配置项目中,跟踪 Debug 输出均处于活动状态。该项目将从这两个类生成输出到所有 Listener 对象。但是,发布解决方案配置项目仅从 Trace 类生成输出。 发布解决方案配置项目将忽略任何 Debug 类方法调用。

You can use the Trace and the Debug classes separately or together in the same application. In a Debug Solution Configuration project, both Trace and Debug output are active. The project generates output from both of these classes to all Listener objects. However, a Release Solution Configuration project only generates output from a Trace class. The Release Solution Configuration project ignores any Debug class method invocations."

以下是一些与您相关的项目可能会发现有用:

Here are some relevant items that you might find useful:

  • Where to look for trace logs ?
  • How to set Debug or Release Configurations ?
  • Understanding build configurations.

这篇关于Console.writeline()/trace.writeline()之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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