Tim
Tim

Reputation: 51

Logging with SuperDevMode. System.out.println not working

Why?

When use System.out.println in client - nothing is output in console of CodeServer.

Now I'm logging in browser console, but how to log in system console?

p.s. I know that best way for logging in gwt is using com.google.gwt.logging.Logging module. It's also now working with system console.

Upvotes: 4

Views: 2667

Answers (3)

mcallahan
mcallahan

Reputation: 79

Not the prettiest of solutions but you can create a native JSNI method like this:

public static native void debug(String text)/*-{
    console.debug(text)
}-*/;

Then just call:

debug("text here").

And it should output to the console.

Upvotes: 1

Arne
Arne

Reputation: 1404

I set up a remote logger to solve this problem. This way all the client log statements are sent to the server where the logging still works. You can find instructions here: Setup a remoteLoggingServlet in GWT.

Then you can use normal java util logging.

import java.util.logging.Logger;
private static Logger log = Logger.getLogger("mylogger");

Stack traces are unfortunately in javascript. I haven't figured out how to get proper java ones yet. Hope this helps!

Upvotes: 1

Daniel Kurka
Daniel Kurka

Reputation: 7985

The super dev mode is basically the same than a production compile (it just does not optimize)

In production (compiled javascript) System.out does not print anything into your java server side process. Your code runs in the Javascript VM and it would need to go over the wire to print to the java console.

If you are running in dev mode you are running inside the JVM that is connected to a plugin inside your browser. This is why System.out works.

Upvotes: 4

Related Questions