Setup a remoteLoggingServlet in GWT

11,667

Solution 1

You should define remote_logging servlet in your web.xml:

<!-- 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>

Solution 2

I found this blog post very helpful:

https://vegdave.wordpress.com/2013/02/26/howto-setup-gwt-remote-logging/

App.gwt.xml:

<inherits name=”com.google.gwt.logging.Logging”/>
<set-property name=”gwt.logging.simpleRemoteHandler” value=”ENABLED” />
<set-property name=”gwt.logging.logLevel” value=”FINEST”/>
<set-property name=”gwt.logging.enabled” value=”TRUE”/>
<set-property name=”gwt.logging.consoleHandler” value=”ENABLED” />
<set-property name=”gwt.logging.popupHandler” value=”DISABLED” />

web.xml:

<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_MODULE/remote_logging</url-pattern>
</servlet-mapping>

In GWT:

import com.google.gwt.logging.client.SimpleRemoteLogHandler;
import java.util.logging.Level;
import java.util.logging.LogRecord;

SimpleRemoteLogHandler remoteLog = new SimpleRemoteLogHandler();
remoteLog.publish(new LogRecord(Level.INFO, “log message”));
Share:
11,667
Josh
Author by

Josh

Updated on June 07, 2022

Comments

  • Josh
    Josh 4 months

    From http://code.google.com/intl/es-ES/webtoolkit/doc/latest/DevGuideLogging.html under the remote logging section it says that you need to

    You will also need to serve the remoteLoggingServlet.

    I would like to use the remote logging feature but I cannot find an example of how to do this step.

    I have setup the following in my .gwt.xml

    <!-- Logging configuration -->
      <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.simpleRemoteHandler" value="ENABLED" />  
      <set-property name="gwt.logging.developmentModeHandler" value="ENABLED" />  
      <set-property name="gwt.logging.systemHandler" value="ENABLED" />
      <set-property name="gwt.logging.popupHandler" value="DISABLED" />
      <set-property name="gwt.logging.consoleHandler" value="DISABLED"/> 
      <set-property name="gwt.logging.firebugHandler" value="DISABLED" />   
    

    The logs appear in the std.out console and the dev mode console but with the remote logging I get the following error

    SEVERE: Remote logging failed: com.google.gwt.user.client.rpc.StatusCodeException: 404

    at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:209) at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287) at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395) at sun.reflect.GeneratedMethodAccessor23.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:129) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) at com.google.gwt.core.client.impl.Impl.apply(Impl.java) at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214) at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352) at java.lang.Thread.run(Unknown Source)