Share via


How do I get Debug output from printf/cout in an MFC Application?

Question

Wednesday, March 4, 2009 5:27 AM

Using Visual Studio 2008.

I created a new MFC Application. (Is this the most comprehensive framework/library if I want to avoid .NET dependencies?)

I'm trying to output debug messages via printf/cout. Nothing appears. In Visual Studio, there's no "Debug Output" pane, only a "Build Output" which shows me the errors/warnings/messages while building my project.

I don't want to have to step through with the debugger because I want a quick run-through of the software and compile a good heap of debug messages I can review at one glance.

All replies (5)

Wednesday, March 4, 2009 5:48 AM âś…Answered

Use either OutputDebugString or AfxTrace (which internally uses OutputDebugString) also takes variable number of arguments. To see debug view in Visual studio 2008, goto Debug (Menu)->Windows->Output.


http://nibuthomas.wordpress.com


Wednesday, March 4, 2009 5:45 AM

Consider OutputDebugString(). You can view the output either using the debugger (in the Output frame), or with a tool like DebugView.


Wednesday, March 4, 2009 8:00 AM

Nibu Thomas said:

Use either OutputDebugString or AfxTrace (which internally uses OutputDebugString) also takes variable number of arguments. To see debug view in Visual studio 2008, goto Debug (Menu)->Windows->Output.


http://nibuthomas.wordpress.com

I turned on the Debug (Menu)->Windows->Output. Used AfxTrace(_T("Hi There");. No output at all.


Wednesday, March 4, 2009 8:02 AM

viewport said:

Nibu Thomas said:

Use either OutputDebugString or AfxTrace (which internally uses OutputDebugString) also takes variable number of arguments. To see debug view in Visual studio 2008, goto Debug (Menu)->Windows->Output.


http://nibuthomas.wordpress.com

I turned on the Debug (Menu)->Windows->Output. Used AfxTrace(_T("Hi There");. No output at all.

Oops. I hit Ctrl+F5 (no debugging) instead of F5. Works now. Thanks.


Wednesday, March 4, 2009 9:27 AM

With debug view (as suggested by Brian) it's possible to see the output when using Ctrl + F5, except that VS won't show the logs but instead debug view.
http://nibuthomas.wordpress.com