HOWTO: Redirecting WFC Debug Output to the VJ6 Output Window

ID: Q194187

The information in this article applies to:

SUMMARY

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.

MORE INFORMATION

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.

Additional query words:

Keywords          : kbVJ600 
Version           : WINDOWS:6.0
Platform          : WINDOWS
Issue type        : kbhowto

Last Reviewed: November 4, 1998