Thursday, June 9, 2011

Remote logging in GWT in 3 easy steps

Steps to setup remote logging in GWT:

1) Add to app.gwt.xml:

<inherits name="com.google.gwt.logging.Logging"/>
<set-property name="gwt.logging.popupHandler" value="DISABLED"/>
<set-property name="gwt.logging.simpleRemoteHandler" value="ENABLED"/>

1st line adds logging module to the project
2nd line disables annoying logging popup
3rd line enables server side logging

2) Add to 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>/app/remote_logging</url-pattern>
</servlet-mapping>


3) Use standard JDK logging api like this:

import java.util.logging.Logger;
...
Logger log = Logger.getLogger(App.class.getName());

Followers