29

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)

Josh
  • 838
  • 3
  • 11
  • 22

2 Answers2

36

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>
Popandopolos
  • 628
  • 6
  • 15
  • Looks like IntelliJ wants to autocorrect "your-gwt-module-name" to "com.google.gwt.logging.Logging". I used my gwt module name, and not the text directly. – Kieveli Sep 28 '11 at 15:20
  • 4
    Off course: "your-gwt-module-name" refers to the fact you should put the name of YOUR GWT module here, as it appears in the /war directory, and probably done via a "rename-to" XML attribute in your .gwt.xml file. Make sure that path you define is reachable on your server and the name doesn't clash with anything else. – Andrew Mackenzie Jul 14 '12 at 14:38
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”));
Michael
  • 32,527
  • 49
  • 210
  • 370
  • Logger logger = Logger.getLogger("simpleRemoteHandler"); logger.log(Level.SEVERE, "this message should get logged"); – googol4u Sep 07 '17 at 14:06