【问题标题】:gwt logs are not generated不生成 gwt 日志
【发布时间】:2012-06-22 06:46:01
【问题描述】:

使用 gwt logs jar 我可以在控制台上显示日志。但是现在我想从 cient 端在我的 olgs 文件中添加日志,就像我们在服务器端使用 log4j 一样。所以我参考了http://code.google.com/p/gwt-log/wiki/GettingStarted这个链接,但我没有看到在我的日志文件中生成任何客户端日志。

以下是我的 gwt.xml 文件

<inherits name="com.allen_sauer.gwt.log.gwt-log-DEBUG" />
<set-property name="log_DivLogger" value="DISABLED" />
<!-- In gwt-log-3.0.3 or later -->
<inherits name="com.allen_sauer.gwt.log.gwt-log-RemoteLogger" />
<set-configuration-property name="log_pattern" value="%d [%t] %p - %m
   %n" />

以下是我的 web.xml 文件

<servlet>
<servlet-name>gwt-log-remote-logger-servlet</servlet-name>
<servlet-class>com.allen_sauer.gwt.log.server.RemoteLoggerServiceImpl</servlet-class>
<!--
   The `symbolMaps` parameter specifies the server directory
    containing the GWT compiler symbol maps output, which is used
     for stack trace deobfuscation
    -->
  <init-param>
       <!-- This value assumes a GWT compile with '-deploy war/WEB-INF/deploy/' -->
      <param-name>symbolMaps</param-name>
       <!--
     Modify the param-value based on your server environment. Some web servers
    use your `war` directory as the 'current working dir', while other
    vendors will do something different. You may use trial and error. Specify the
    relative path you think should work, then check the server log after forwarding
    the first client log message to the server. If the directory cannot be found,
    gwt-log will report the full path which it tried.
  -->
  <param-value>WEB-INF/deploy/detectfiles/symbolMaps/</param-value>
  </init-param>

  <!--
    Additional or alternate directories may be specified via additional parameter
  which also begin with `symbolMaps`. This may be useful if you deploy to multiple
  server environments which use different directory structures or have a different
  notion of what the 'current working directory' is.
 --> 
 <init-param>
   <param-name>symbolMaps_2</param-name>
   <param-value>WEB-INF/deploy/detectfiles/symbolMaps/</param-value>
 </init-param>

     <!-- Optionally enable CORS (http://www.w3.org/TR/cors/)
  <init-param>
     <param-name>Access-Control-Allow-Origin</param-name>
     <param-value>http://your-applications-origin</param-value>
  </init-param> 
  -->
</servlet>

<servlet-mapping>
    <servlet-name>gwt-log-remote-logger-servlet</servlet-name>
  <url-pattern>/com.renault.detectfiles/gwt-log</url-pattern>
  </servlet-mapping>

我在clinet端添加了如下日志

        Log.debug("Hi this is a debug log");

【问题讨论】:

    标签: gwt logging log4j


    【解决方案1】:

    首先,确保使用附加参数 -deploy war/WEB-INF/deploy/ 编译 GWT 应用程序。

    其次,确保目录中存在符号映射 WEB-INF/deploy/detectfiles/symbolMaps/。我观察到,当我编译时,symbolMaps 会进入目录WEB-INF/deploy/&lt;module-name&gt;/symbolMaps/。在这里,detectfiles 看起来不像您的模块名称。因为,在 url-pattern 中,您已将 com.renault.detectfiles 指定为模块名称。

    这些可能是看不到日志的可能原因。

    【讨论】:

    • 嗨,是的,我的模块名称检测文件。所以在我的 url 模式中,我将其更改为 just/detectfiles/gwt-log。并且符号图确实存在于指定的目录中。但仍然没有生成日志:(
    • 不确定是什么问题。您可以做一件事来检查服务器端的配置是否正确。将调试日志放入您的 servlet 并检查它是否工作正常。
    • 调试日志工作正常。奇怪的是,没有与 gwt 日志相关的错误或异常...我确定在某个地方我错过了一些小事情...如果您之前使用过 gwt-logs,您可以在此处粘贴一个示例,以便我会比较验证吗?
    • 我刚刚尝试了 gwt-log 的 GettingStarted 页面中提供的示例。我能够在服务器控制台中看到客户端日志。
    • 您有两个条目重复或不正确。它们是 symbolMaps_2 和 Access-Control-Allow-Origin。删除这些参数并尝试一下
    猜你喜欢
    • 2021-12-01
    • 1970-01-01
    • 2016-05-12
    • 1970-01-01
    • 2021-02-14
    • 1970-01-01
    • 2014-06-16
    • 1970-01-01
    相关资源
    最近更新 更多