GWT logging in Production mode with Console Handler - gwt

I have enabled GWT logging with ConsoleHandler as shown below.
<inherits name="com.google.gwt.logging.Logging"/>
<set-property name="gwt.logging.logLevel" value="INFO"/>
<set-property name="gwt.logging.enabled" value="TRUE"/>
<set-property name="gwt.logging.consoleHandler" value="ENABLED"/>
Because of this I also see a logging window appearing on application page and logs in console of the browser as shown here which is obvious.
How do I disable the window appearing on my application and have only browser console on in production mode?
Is it that we have to disable the ConsoleHandler? Or may be I have to use SimpleRemoteLogHandler when in production mode?
There is also a FirebugLogHandler but limited to Firebug.

In your case to disable the popup -
<set-property name="gwt.logging.popupHandler" value="DISABLED" />
You can also configure other details. In our case we go with following
<set-property name="gwt.logging.enabled" value="TRUE" />
<set-property name="gwt.logging.logLevel" value="FINEST" />
<set-property name="gwt.logging.consoleHandler" value="ENABLED" />
<set-property name="gwt.logging.developmentModeHandler"
value="ENABLED" />
<set-property name="gwt.logging.firebugHandler" value="ENABLED" />
<set-property name="gwt.logging.hasWidgetsHandler" value="DISABLED" />
<set-property name="gwt.logging.popupHandler" value="DISABLED" />
<set-property name="gwt.logging.systemHandler" value="ENABLED" />
<set-property name="gwt.logging.simpleRemoteHandler"
value="DISABLED" />

When you <inherits name="com.google.gwt.logging.Logging"/> most log handlers are enabled already, including the popupHandler which is responsible for the window popping up.
You'll want to disable all those you don't want/need rather than enable the one you want.
See https://code.google.com/p/google-web-toolkit/source/browse/tags/2.5.0/user/src/com/google/gwt/logging/LoggingDisabled.gwt.xml#132
As a side note, gwt.logging.logLevel already defaults to INFO and gwt.logging.enabled is set to TRUE already in com.google.gwt.logging.Logging.

Related

How to debug GWT client code in JBoss?

I am working on a Java/J2EE web project in which all GUI is developed in GWT(V2.5.1). We have deployed WAR files in JBoss 7.1. Now I want to debug the UI/client side code in eclipse Luna(4.4). I have tried a lots of ways to debug but not successful. Is there any way/third party tool/eclipse plugin to debug the GWT code. Please help me to debug the code. Thanks in advance. (Also let me know the way of logging in GWT).
You can't debug GWT client code once it is deployed as a war.
You can only debug using SuperDevMode using the debugging tools of the browser (I prefer Chrome for this).
Logging is done using java.util.Logger after putting some stuff in your gwt.xml
<inherits name="com.google.gwt.logging.Logging"/>
<inherits name="be.gps.gwt.shared.Shared"/>
<set-property name="gwt.logging.enabled" value="TRUE" />
<set-property name="gwt.logging.developmentModeHandler" value="ENABLED" />
<set-property name="gwt.logging.systemHandler" value="DISABLED" />
<set-property name="gwt.logging.consoleHandler" value="ENABLED"/>
<set-property name="gwt.logging.simpleRemoteHandler" value="DISABLED" />
<set-property name="compiler.stackMode" value="emulated" />
<set-configuration-property name="compiler.emulatedStack.recordLineNumbers" value="true"/>
<set-configuration-property name="compiler.emulatedStack.recordFileNames" value="true"/>
<replace-with class="be.gps.gwt.jsonrpclogger.client.JsonRpcRemoteLogHandler">
<when-type-is class="com.google.gwt.logging.client.SimpleRemoteLogHandler" />
<any>
<when-property-is name="gwt.logging.enabled" value="TRUE" />
<when-property-is name="gwt.logging.simpleRemoteHandler" value="ENABLED" />
</any>
</replace-with>

How To Find Root Cause for GWT Permutations

I have rather large GWT project that depends on a number of third party libraries. When compiling the GWT part of the application, I see that the GWT compiler goes through 10 permutations. But I'm only compiling for 5 different browsers, and for one locale. How can I figure out what is causing the each permutation? Is there some setting I can enable that prints out what each permutation is for when it is compiled. Something that would give me output like:
Compiling Permutation 0 - Browser ie8 and Locale En ....
Compiling Permutation 1 - Browser ie9 and Locale En ....
My gwt.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!--
When updating your version of GWT, you should also update this DTD reference,
so that your app can take advantage of the latest GWT module capabilities.
-->
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.0//EN"
"http://google-web-toolkit.googlecode.com/svn/tags/2.5.0/distro-source/core/src/gwt-module.dtd">
<module rename-to='LibraryPlace'>
<inherits name="com.github.gwtbootstrap.BootstrapNoResources"/>
<inherits name='com.biglibrary.libraryplace.model.LibraryModel'/>
<inherits name="com.biglibrary.common.LiCommon"/>
<inherits name="org.atmosphere.gwt20.AtmosphereGwt20"/>
<inherits name='com.google.web.bindery.event.EventBinder'/>
<inherits name="com.google.gwt.logging.Logging"/>
<stylesheet src="/css/datepicker.css"/>
<!-- LATO font -->
<!--<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic">-->
<!-- Bootstrap CSS -->
<stylesheet src="http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic"/>
<!--<stylesheet src="/css/bootstrap.css"/>
<stylesheet src="/css/bootstrap-responsive.css"/>-->
<stylesheet src="/css/toastr.css"/>
<stylesheet src="/css/fullcalendar.css"/>
<!-- Library Place New Custom CSS based on MyAdmin Theme Custom CSS -->
<stylesheet src="/css/style.css"/>
<stylesheet src="/css/clock/clock-style.css"/>
<source path='resources'/>
<replace-with class="com.biglibrary.libraryplace.resources.LibraryConfigurator">
<when-type-is class="com.github.gwtbootstrap.client.ui.config.Configurator"/>
</replace-with>
<public path="resources">
<exclude name="** /*.java"/>
<exclude name="** /*.class"/>
</public>
<!-- Other module inherits-->
<inherits name="de.devbliss.gwt.xdm.XDM"/>
<inherits name="com.watopi.chosen.Chosen"/>
<!-- enable #CORS annotations in restygwt -->
<extend-configuration-property
name="org.fusesource.restygwt.annotationresolver"
value="org.fusesource.restygwt.rebind.CORSAnnotationResolver"/>
<replace-with class="de.devbliss.gwt.xdm.client.impl.CORSTransportLayer">
<when-type-is class="com.biglibrary.libraryplace.client.xdr.XDRTransportLayer"/>
<any>
<when-property-is name="user.agent"
value="gecko1_8"/>
<when-property-is name="user.agent"
value="safari"/>
</any>
</replace-with>
<inherits name="com.google.gwt.logging.Logging"/>
<!-- gwt logging properties -->
<set-property name="gwt.logging.logLevel"
value="FINE"/>
<set-property name="gwt.logging.popupHandler"
value="ENABLED">
<any>
<when-property-is name="user.agent"
value="ie8"/>
<when-property-is name="user.agent"
value="ie9"/>
</any>
</set-property>
<!--Gives java like stack trace for errors that come up in js-->
<set-property name="compiler.emulatedStack"
value="true"/>
<set-configuration-property
name="compiler.emulatedStack.recordFileNames"
value="true"/>
<!-- Specify the app entry point class. -->
<entry-point class='com.biglibrary.libraryplace.client.LibraryPlace'/>
<!--Chrome or Safari-->
<set-property name="user.agent" value="opera,ie8, gecko1_8, safari, ie9"/>
<!-- Specify the paths for translatable code -->
<source path='client'/>
<define-configuration-property name="gin.ginjector"
is-multi-valued="false"/>
<set-configuration-property name="gin.ginjector"
value="com.biglibrary.libraryplace.client.gin.AppGinjector"/>
<!--
Ensure Ui Binder files are using Safe HTML to prevent XSS.
-->
<set-configuration-property name="UiBinder.useSafeHtmlTemplates"
value="true"/>
<!-- English language, independent of country. -->
<extend-property name="locale"
values="en"/>
<!-- Default language (English) -->
<set-property-fallback name="locale"
value="en"/>
<add-linker name="xsiframe"/>
<set-configuration-property name="gwt.superdevmode"
value="on"/>
<set-configuration-property name="devModeRedirectEnabled"
value="true"/>
<set-property name="compiler.useSourceMaps"
value="true"/>
</module>
As you are compiling your project using the xsiframe linker you will have a compilation-mappings.txt file in your javascript folder.
It contains a very useful list with all permutations and the properties which triggers each one.
F7437BC8947642CC76A8E491E7E52DB4.cache.js
mgwt.os desktop
user.agent safari
F7437BC8947642CC76A8E491E7E52DB4.cache.js
mgwt.os desktop
user.agent gecko1_8
[...]
Once you know which properties produce each permutation, you can dive into *.gwt.xml files to know which properties are increasing the permutation number.
In your case, if you are using just en language, it is better not set it at all, so as gwt will compile only default, otherwise it is compiling default and en languages.
Another useful option for reducing permutations is to use the collapse-property feature.
<collapse-property name="language" values="*" />
My guess is that it's compiling 5xfor english and 5xfor the default locale (which happens to be English as well).
Thomas Broyer's comment led me to discover that GWT can make a compile report:
http://www.gwtproject.org/doc/latest/DevGuideCompileReport.html
It gave me a nice print out of why each permutation was being created. Thanks!

Where can I find the log file from GWT's remoteLoggingServlet?

It runs without any log information. I can't find the log file on server anywhere, also didn't find any console info on server(because I don't know which console these log info will be displayed on). Should I do some further config or coding? Thanks.
I have configured GWT-Logging in .gwt.xml as below:
<inherits name="com.google.gwt.logging.Logging"/>
<set-property name="gwt.logging.enabled" value="TRUE"/>
<set-property name="gwt.logging.logLevel" value="FINE"/>
<set-property name="gwt.logging.popupHandler" value="DISABLED" />
<set-property name="gwt.logging.firebugHandler" value="DISABLED" />
<set-property name="gwt.logging.developmentModeHandler" value="DISABLED" />
<set-property name="gwt.logging.consoleHandler" value="DISABLED" />
<set-property name="gwt.logging.systemHandler" value="DISABLED" />
<set-property name="gwt.logging.simpleRemoteHandler" value="ENABLED"/>
remoteLoggingServlet has already been configured in web.xml:
<servlet>
<servlet-name>remoteLoggingServlet</servlet-name>
<servlet-class>com.google.gwt.logging.server.RemoteLoggingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>remoteLoggingServlet</servlet-name>
<url-pattern>/my.app.class.name/remote_logging</url-pattern>
</servlet-mapping>
in GWT Client codeļ¼š
Logger logger = Logger.getLogger("NameOfYourLogger");
logger.log(Level.SEVERE, "this message should get logged ok!");
web client runs, but where is log file on server? Thanks.
for log-files:
After I put a logging.properties file under war\WEB-INF\classes, it works on tomcat if I deploy the GWT project. The location is tomcat\bin if you doesn't specify any path.
It still doesn't work in GWT devMode, maybe the Jetty server in devMode under eclipse works in a different way. But you can enable other handlers to find the log info on eclipse consoles. So far, that's enough for me.
Don't you need:
/your-gwt-module-name/remote_logging
and not
/my.app.class.name/remote_logging
in
<!-- remote logging -->
<servlet>
<servlet-name>remoteLogging</servlet-name>
<servlet-class>com.google.gwt.logging.server.RemoteLoggingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>remoteLogging</servlet-name>
<url-pattern>/your-gwt-module-name/remote_logging</url-pattern>
</servlet-mapping>

Java GWT remoteLoggingServlet - can I configure java.util.Logging to send this to a log file?

Is it possible to get messages received on the server, from client side logging via the remoteLoggingServlet in GWT to write to a file?
http://code.google.com/intl/es-ES/webtoolkit/doc/latest/DevGuideLogging.html#Remote_Logging
I have GWT Logging set up successfully in my .gwt.xml
<set-property name="gwt.logging.enabled" value="TRUE"/>
<set-property name="gwt.logging.logLevel" value="FINE"/>
<set-property name="gwt.logging.popupHandler" value="DISABLED" />
<set-property name="gwt.logging.firebugHandler" value="DISABLED" />
<set-property name="gwt.logging.developmentModeHandler" value="DISABLED" />
<set-property name="gwt.logging.consoleHandler" value="DISABLED" />
<set-property name="gwt.logging.systemHandler" value="DISABLED" />
<set-property name="gwt.logging.simpleRemoteHandler" value="ENABLED"/>
And the remote logging servlet set up:
<servlet>
<servlet-name>remoteLoggingServlet</servlet-name>
<servlet-class>com.google.gwt.logging.server.RemoteLoggingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>remoteLoggingServlet</servlet-name>
<url-pattern>/my.app.class.name/remote_logging</url-pattern>
</servlet-mapping>
I see my error messages on the development console.
I had hoped since the remote logging service
http://www.google.com/codesearch#A1edwVHBClQ/user/src/com/google/gwt/logging/server/RemoteLoggingServiceUtil.java&is_navigation=1
appears to use java.util.Logging under the covers, that I would be able to configure this to log to a log file, so that I could see what errors users were getting on the client side, to diagnose some performance problems.
Has anyone had any luck configuring messages to go somewhere other than client side displays?
For what it's worth - I have decided to work around this by reimplementing my own
RemoteLoggingServiceImpl and RemoteLoggingServiceUtil
And switching these from using java.util.Logging to using Log4j once the messages are on the server side.

GWT compile - why still 5 permutations after only having one user.agent option?

Trying to speed up gwt compile, did the following:
<module rename-to=xxxx>
<inherits name='com.yyy.basemodule>
<set-property name="user.agent" value="ie6"/>
<extend-property name='locale' values='en' />
</module>
But when compiling, expecting only permutation, still saying:
"Compiling 5 permutations"
Any clue?
Use <set-property name="locale" value="default"/> instead of the extend-property tag.