2012-06-22 97 views
1

使用gwt日誌jar我可以在我的控制檯上顯示日誌。但是現在我想從cient端添加日誌到我的olgs文件中,因爲我們在服務器端使用log4j。所以我回到http://code.google.com/p/gwt-log/wiki/GettingStarted這個鏈接,但我沒有看到任何客戶端日誌在我的日誌文件中生成。gwt日誌不生成

以下是我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" /> 

以下是我已經加入登錄客戶爲例側如下

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

回答

0

首先我的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> 

所有,請確保使用附加參數-deploy war/WEB-INF/deploy /編譯您的GWT應用程序。

其次,請確保符號圖存在於目錄 WEB-INF/deploy/detectfiles/symbolMaps/中。我觀察到符號映射在我編譯時轉到目錄WEB-INF/deploy/<module-name>/symbolMaps/。在這裏,detectfiles看起來不像你的模塊名稱。因爲在url-pattern中,您已指定com.renault.detectfiles作爲模塊名稱。

這些可能是未看到日誌的可能原因。

+0

嗨,是的,我的模塊名稱detectfiles。所以在我的url模式中,我將其更改爲/ detectfiles/gwt-log。符號映射確實存在於指定的目錄中。但仍然沒有生成日誌:( – Madhura

+0

)不知道是什麼問題,你可以做一件事情來檢查服務器端的配置是否正確,把調試日誌放到你的servlet中,並檢查它是否正常工作 –

+0

debug log works很奇怪,沒有與gwt日誌相關的錯誤或異常......我確信在某個地方我錯過了一些次要的東西......如果你以前使用過gwt-logs,你可以在這裏粘貼一個例子我將比較和驗證? – Madhura