How to see debugging statements in a Release build on Windows?

I need to debug an issue in our Release build on Windows, but can’t seem to get any output to show up anywhere. I tried using MessageBox, but that required that I add <Windows.h>, which then generated conflicts with basic types such as Rectangle when building.

On Mac, I can fprintf to stderr, but neither stderr nor stdout seem to show up when running a DAW from the command line like I can do on the Mac.

How can I generate and see some kind of debugging statements in a Release build?

1 Like

I use a FileLogger and watch its contents by doing a tail -f on the log file being generated.

Hmm. A FileLogger requires managing its lifetime someplace, which I’m not sure how to implement easily in a form similar to DBG. And it has to only be turned on when I set a flag someplace in the code, so I don’t generate this info for users, only for my own testing.

Is there a way to see stdout or stderr output on the PC when not in a debugger? If so, I could use fprintf.

1 Like

You could use Juce’s Logger::writeToLog and DebugView to view the messages. (writeToLog uses OutputDebugStr on Windows to output the messages, printf on other systems.)

Actually it is simpler than that, it is implemented as a Singleton with many convenience methods.

To set a FileLogger do this in the constructor, only once per process necessary:

Logger::setDefaultLogger (FileLogger::createDateStampedLogger (/*...*/));

If you omit this line, it will fall back to log via DBG, i.e. do nothing in release builds. So it is very simple to add e.g a command line argument to turn it on or off…

And to log, there is a static call as well, so really simple to use:

Logger::writeToLog ("Whatever to log: " + String (foo));

(not sure, if the convenient << operator works here as well, like in DBG, try it out…)


Looks like you meant setCurrentLogger, not setDefaultLogger. Thanks, though, that helps!

Oh yes, indeed. Thanks for the correction :slight_smile: