在GWT文档中查找所有信息有点困难,您需要设置这些信息以进行模糊处理日志记录,因此以下是简短版本:
在您的模块文件(.gwt.xml)中,添加:
<inherits name="com.google.gwt.logging.Logging"/><set-property name="gwt.logging.simpleRemoteHandler" value="ENABLED" /><set-property name="compiler.stackMode" value="emulated" /><set-configuration-property name="compiler.emulatedStack.recordLineNumbers" value="true" />
在客户端,使用类似
import java.util.logging.Logger;private static Logger rootLogger = Logger.getLogger("");...rootLogger.log(Level.SEVERE, "My message", e);您无需
RemoteLoggingServiceAsync在客户端上创建实例-记录器会自动使用该实例,因为我们指定了
<set-propertyname="gwt.logging.simpleRemoteHandler" value="ENABLED" />。
在服务器端,配置RemoteLoggingServiceImpl。您将不得不告诉它,它在哪里找到symbolMaps,它将在使用GWT编译器参数进行编译时生成
-extra/path/to/myExtraDir。我个人使用的方法来覆盖RemoteLoggingServiceImpl,允许从指定的web.xml的目录
<init-param>小号[*]
package mypackage.server;public class ConfigurableRemoteLoggingServiceImpl extends RemoteLoggingServiceImpl { @Override public void init(final ServletConfig config) throws ServletException { super.init(config); final String symbolMapsDirectory = config.getInitParameter("symbolMapsDirectory"); setSymbolMapsDirectory(symbolMapsDirectory); }}在中
web.xml,像注册
<servlet> <servlet-name>remoteLogging</servlet-name> <servlet-class>mypackage.server.ConfigurableRemoteLoggingServiceImpl</servlet-class> <init-param> <param-name>symbolMapsDirectory</param-name> <param-value>/path/to/myExtraDir/mymodulename/symbolMaps</param-value> </init-param></servlet><servlet-mapping> <servlet-name>remoteLogging</servlet-name> <url-pattern>/mymodulename/remote_logging</url-pattern></servlet-mapping>
替换
/path/to/myExtraDir,
mymodulename并
mypackage用自己的价值观,不要忘记调用与GWT编译器
-extra参数(请注意,您不必使用
-stylePRETTY或详细,它也与OBF的作品)。保留所有生成的symbolMap:如果没有它们,消除混淆将不起作用。由于每个新版本都会自动获得唯一的名称,因此您在构建时可以将它们全部收集在安全的中央位置。
[*]我真的,真的很奇怪,为什么RemoteLoggingServiceImpl本身没有实现!



