Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get Debug.WriteLine to write to the output window in Release mode?

Ok, I realize that the question sounds ridiculous. Why would you wanna debug in release mode? I'm trying to implement an ILogger interface that when implemented, provides a facade for logging (obviously). For the most part, that facade writes out to enterprise library -- so it already has a Debug method with it's own configuration. The problem is that I simply add Debug.WriteLine("msg") line to the facade in addition to it's normal behavior of writing out to a file, when I build it in Release mode, those debug statements don't get compiled with it so it won't write to the console when using that library from a different project, even if that project is built in debug.

What I would like is to set up this facade so that regardless of how it is built, all Logger.Debug messages will be output to the window and not just the file generated by MEL. Can I just set up the System.Diagnostics object to always compile, or is there a way to set up enterprise library to use the output as a configured listener?

like image 302
Sinaesthetic Avatar asked Feb 11 '23 07:02

Sinaesthetic


1 Answers

You can use Trace.WriteLine instead. Just make sure that TRACE is defined in the Release settings (it is by default).

Technically speaking, you could make DEBUG defined in Release mode, either via project settings or explicitly:

#define DEBUG

But it would be weird.

like image 139
AlexD Avatar answered Feb 13 '23 02:02

AlexD