How to make Debug.WriteLine write to the output window in Release mode?

Well, I understand that the question sounds funny. Why do you want to debug in release mode? I am trying to implement the ILogger interface, which when implemented provides a facade for logging (obviously). For the most part, this facade is written to the corporate library, so it already has a Debug method with its own configuration. The problem is that I just add the line Debug.WriteLine ("msg") to the facade in addition to the normal behavior of writing to a file, when I create it in Release mode, these debugging instructions will not compile with it so it will not write to the console when using this library from another project, even if this project is embedded in debugging.

I would like to configure this facade so that no matter how it is built, all Logger.Debug messages will be displayed in the window, and not just the file created by MEL. Can I just configure the System.Diagnostics object for compilation or is there a way to configure the corporate library to use output as a configured listener?

+4
source share
1 answer

You can use instead Trace.WriteLine. Just make sure it is TRACEdefined in the Release settings (default).

From a technical point of view, you can do something DEBUGdefined in release mode, either through the project settings, or explicitly:

#define DEBUG

But that would be strange.

+8

Source: https://habr.com/ru/post/1584976/


All Articles