Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write to Debug in release mode

I have an exception that I need to swallow (exception during logging), however I dont want the exception information to be completely lost to the mists of time and so I figured I may as well at least output it to debug using

Debug.Write(ex.ToString());

That way if it becomes necessary support can at least use DebugView on the machine having problems.

Trouble is the Debug class is removed in release mode - how do I output something to debug whilst in release mode?

like image 352
Justin Avatar asked Aug 06 '09 09:08

Justin


1 Answers

Simply use

Trace.Write(ex.ToString());

This does the same as Debug.Write(ex.ToString()); but won't be removed in Release mode (as long as you didn't remove the definition of the TRACE constant in your project settings)

like image 56
Dirk Vollmar Avatar answered Sep 29 '22 04:09

Dirk Vollmar