Search code examples
gwt

How to print to the console in GWT


I am debugging a GWT application and I need to print some stuff to the console for testing purposes. System.out.println and GWT.log don't work. Does anyone have any ideas?


Solution

  • Quoting the documentation:

    Adding GWT logging is really quite simple, as simple as the following code example. However — understanding how logging works, and how to correctly configure it is important, so please do take the time to read the rest of this document.

    http://code.google.com/webtoolkit/doc/latest/DevGuideLogging.html

    The simplest way to enable logging is:

    # In your .gwt.xml file
    <inherits name="com.google.gwt.logging.Logging"/>
    
    # In your .java file
    Logger logger = java.util.logging.Logger.getLogger("NameOfYourLogger");
    logger.log(Level.SEVERE, "this message should get logged");