Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 194187 - Last Review: July 2, 2004 - Revision: 1.1
How To Redirecting WFC Debug Output to the VJ6 Output Window
This article was previously published under Q194187
The WFC debugging class, com.ms.wfc.util.Debug, contains a number of useful
methods for emitting debug messages during a debug session. An attractive
feature of these methods is that the conditional compilation facility of
the Visual J++ 6.0 compiler causes all of the Debug methods not to be
included in your "retail" builds, giving both size and speed optimizations.
These messages, when used from within WJVIEW session spawned under the
Visual J++ 6.0 debugger will automatically appear in the Visual J++ 6.0
Output window so that you can easily view them while debugging. However,
when your are building a Java CONSOLE application that uses JVIEW, the
Debug messages appear by default in the CONSOLE application window, not in
the Visual J++ Output window.
It is possible to redirect the JVIEW WFC Debug messages to the Visual J++
6.0 Output window by using the com.ms.debug.Debugger.out.println() method
call.
Note that com.ms.debug.Debugger.out.println() always outputs to the Visual
J++ Output window in both Retail and Debug builds and can be a useful way
to emit runtime debug messages. However, since the WFC Debug classes have
more functionality and are compiled out of the retail builds, they are the
preferred way to show diagnostic messages while developing your
application.
The following code sample shows how to add an event handler for the WFC
Debug class. The event handler is used to redirect WFC Debug messages to
the com.ms.debug.Debugger class, which will emit the message into the
Visual J++ Output window.
// file debugConsole.java
import com.ms.wfc.util.*;
public class debugConsole {
public debugConsole() {
// Add a Debug Message handler
Debug.addOnDisplayMessage(new
DebugMessageEventHandler(this.onDebugMessage));
}
public static void main (String[] args) {
Debug.println("Hello World");
}
private void onDebugMessage(String message) {
// Redirect the wfc.util.Debug messages from the DOS console
// to the VJ6 output window using the MS Java debug package
com.ms.debug.Debugger.out.println(message);
}
}
(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Steve
Horne, Microsoft Corporation.
APPLIES TO
- Microsoft Visual J++ 6.0 Standard Edition
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate