Turning tracing off via app.config

后端 未结 6 1953
孤独总比滥情好
孤独总比滥情好 2020-12-08 05:20

I\'m trying to use System.Diagnostics to do some very basic logging. I figure I\'d use what\'s in the box rather than taking on an extra dependency like Log4Net or EntLib. <

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-08 06:02

    Check the state of dataSwitch whenever you need to log, as per:

    http://msdn.microsoft.com/en-us/library/aa984285%28v=VS.71%29.aspx

    However, that is pretty nasty, having to put those checks everywhere. Is their a reason you don't want to simply remove the TraceListener from the listeners collection in app.config?

    Apart from that, I'd investigate using the .NET 2.0+ trace stuff which includes TraceSource. The new(er) stuff offers a much higher degree of configuration, and you might find it's more suitable.

    http://msdn.microsoft.com/en-us/library/ms228993.aspx

提交回复
热议问题