简体   繁体   English

跟踪到MFC应用程序中的控制台

[英]Trace to Console in MFC application

I am currently tracing my errors in an MFC application to a .log file and to the event viewer, but I would also like to trace to the console. 我目前正在将MFC应用程序中的错误跟踪到.log文件和事件查看器中,但是我也想跟踪到控制台。 A console solution is posted here: http://www.codeproject.com/Articles/612/Creating-a-console-for-your-MFC-app-s-debug-output 控制台解决方案发布在这里: http : //www.codeproject.com/Articles/612/Creating-a-console-for-your-MFC-app-s-debug-output

but I want to be able to turn it on and off easily (Perhaps with a TraceSwitch). 但我希望能够轻松打开和关闭它(也许使用TraceSwitch)。

In addition to the obvious, 除了显而易见的

<add name="LPRConsoleListener" type=System.Diagnostics.ConsoleTraceListener" />

You must put 你必须把

AllocConsole()

in your InitInstance() function before you initialize your MFC Window. 在初始化MFC窗口之前,请在InitInstance()函数中单击。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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