简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM