在GWT中设置remoteLoggingServlet

时间:2011-04-27 23:47:46

标签: gwt logging

来自远程日志记录部分下的http://code.google.com/intl/es-ES/webtoolkit/doc/latest/DevGuideLogging.html,它表示您需要

  

您还需要提供remoteLoggingServlet。

我想使用远程日志记录功能,但我找不到如何执行此步骤的示例。

我在.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" />   

日志显示在std.out控制台和开发模式控制台中但是使用远程日志记录时出现以下错误

严重:远程登录失败: com.google.gwt.user.client.rpc.StatusCodeException:404

在com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:209)     在com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)     在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)     在com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)     在com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)     在com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)     在com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)     在com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)     在com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:129)     在com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)     在com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)     在com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)     在com.google.gwt.core.client.impl.Impl.apply(Impl.java)     在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)     在com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)     在com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)     在com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)     在com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)     在com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)     在com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)     在java.lang.Thread.run(未知来源)

2 个答案:

答案 0 :(得分:34)

您应该在web.xml中定义remote_logging servlet:

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

答案 1 :(得分:2)

我发现这篇博文很有帮助:

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>

在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”));