5

When I write messages to log (i.e. com.allen_sauer.gwt.log.client.Log#debug) I can see them in Chrome->F12->Console or (during debug) in IDEA->Debug->Dev Mode. But if the System.out.println() was used in IDEA the messages appear in the same place as the logged ones, but what about when I am not debugging? where do they go?

niralittle
  • 114
  • 1
  • 3
  • 9

2 Answers2

5

System.out.println() are just removed by the compiler in production mode.

If you want to check just create this simple module:

public class Foo implements EntryPoint {

  public void onModuleLoad() {

    System.out.println("Hello World!");
  }
}

And look at the generated javascript.

StephaneM
  • 4,779
  • 1
  • 16
  • 33
2

The preferred way to do logging (at development time) is com.google.gwt.core.client.GWT.log(). Messages logged this way will also wind up in your browser's console like you mention. Likely System.out.println is mapped to the same functionality for convenience. From the GWT.log Javadoc:

Logs a message to the development shell logger in Development Mode, or to the console in Super Dev Mode. Calls are optimized out in Production Mode.

geert3
  • 7,086
  • 1
  • 33
  • 49