GWT:如何在GWT中将客户端日志写入日志文件
嗨,伙计们,我面临一个大问题,在GWT的文件中写入日志 我浏览了网上所有的帖子,但没有找到任何有价值的信息 在那里 我所做的GWT:如何在GWT中将客户端日志写入日志文件,gwt,Gwt,嗨,伙计们,我面临一个大问题,在GWT的文件中写入日志 我浏览了网上所有的帖子,但没有找到任何有价值的信息 在那里 我所做的 在web.xml文件中添加了远程日志servlet 在my.gwt.xml文件中继承了日志记录模块 但是现在我的问题是假设我在我的入口点类中写了一个日志 像 //Main class to start the appliation..... public void onModuleLoad() { Logger logger=Logger.getLogger
//Main class to start the appliation.....
public void onModuleLoad() {
Logger logger=Logger.getLogger(SYTMain.class.getName());
logger.info("Test Log in Module File");
}
现在我想将这个客户端日志写入test.log文件
我怎样才能做到这一点/
请如果有人知道答案,那么请提供完整的解决方案给我,我不想在飞行的例子。如果你真的知道的话,请告诉我不要给出已经在网上找到的答案
我的交付日期非常接近,所以请尽快更新,我将非常感谢您。在客户端,GWT编译为Javascript,Javascript通常无法将文件写入客户端的文件系统。(这可能是个坏主意的原因应该很明显)。例如,见
如果您需要的是用于调试的日志,一个明显的解决方案是将日志程序附加到页面上的文本区域。您始终可以手动复制并通过另一个文件。或者,如果要远程调试,可以让记录器写入服务器。只需创建一个RPC服务,将其记录到服务器端
使用servlet端threadlocal获取有关客户端的信息:。在模块文件中添加以下内容:
<inherits name='com.google.gwt.logging.Logging'/>
<set-property name="gwt.logging.enabled" value="TRUE"/>
<!-- Set logging level to INFO -->
<set-property name="gwt.logging.logLevel" value="INFO"/>
<set-property name="gwt.logging.simpleRemoteHandler" value="ENABLED" />
<!-- Add compiler.stackMode to get a readable stacktrace from JavaScript
It generates a set of files in WEB-INF/deploy; those files need to
be placed on the server
-->
<set-property name="compiler.stackMode" value="emulated" />
<servlet>
<servlet-name>remoteLoggingService</servlet-name>
<servlet-class>com.google.gwt.logging.server.RemoteLoggingServiceImpl</servlet-class>
</servlet>
<!-- Servlet Mapping -->
<servlet-mapping>
<servlet-name>remoteLoggingService</servlet-name>
<url-pattern>/<your module name>/remote_logging</url-pattern>
</servlet-mapping>
在web.xml中添加以下内容:
<inherits name='com.google.gwt.logging.Logging'/>
<set-property name="gwt.logging.enabled" value="TRUE"/>
<!-- Set logging level to INFO -->
<set-property name="gwt.logging.logLevel" value="INFO"/>
<set-property name="gwt.logging.simpleRemoteHandler" value="ENABLED" />
<!-- Add compiler.stackMode to get a readable stacktrace from JavaScript
It generates a set of files in WEB-INF/deploy; those files need to
be placed on the server
-->
<set-property name="compiler.stackMode" value="emulated" />
<servlet>
<servlet-name>remoteLoggingService</servlet-name>
<servlet-class>com.google.gwt.logging.server.RemoteLoggingServiceImpl</servlet-class>
</servlet>
<!-- Servlet Mapping -->
<servlet-mapping>
<servlet-name>remoteLoggingService</servlet-name>
<url-pattern>/<your module name>/remote_logging</url-pattern>
</servlet-mapping>
远程日志服务
com.google.gwt.logging.server.RemoteLoggingServiceImpl
远程日志服务
//远程日志记录
将
替换为模块名称
要记录日志,只需使用代码作为参考。使用导入自
java.util.logging
我知道这一点,但我的问题是,如何在日志文件中记录客户端活动?如何使用GWT提供的SimpleRemoteHandler。