.net Diagnostics best practices?

前端 未结 4 1383
天命终不由人
天命终不由人 2021-01-30 11:43

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 produc

4条回答
  •  梦谈多话
    2021-01-30 12:25

    You are using it fine except for Assert with first argument hardcoded to true. You should probably add some condition there and the message (second argument) will be printed only if the condition is false. So in your code example it will never be displayed. In some cases WriteLineIf may come in handy if you don't want to wrap your debug statements in conditional blocks.

    Check out the Debug class reference it has quite a few useful methods and properties to help you log things.

提交回复
热议问题