Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
171 views
in Technique[技术] by (71.8m points)

GWT: how to write client side logs into a log file in GWT

HI guys i am facing a big problem to write logs in a file in GWT.

i ahd gone through all the posts over internet but i didn't find any valuable information there.

What i did ...

  1. added remote logging servlet in web.xml file
  2. inherited the logging module in my .gwt.xml file.

But my question is here now suppose i have written one log in my Entry Point class.

like ....

//Main class to start the appliation.....


public void onModuleLoad() {

    Logger logger=Logger.getLogger(SYTMain.class.getName());

    logger.info("Test Log in Module File");
}

and now i want to write this client side log into a test.log file .

How i can achieve this???/

Please if anyone knows the answer then plz provide me the complete solution, i don't want example on a fly. if you really know then only plz tell me don't give the answer which is already available in net.....

mY delivery date is very near so plz update on same ASAP, i'll be very thankful to you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In your module file add the following:

  <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" />

In your web.xml add the following:

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

Replace <your module name> with as it says your module name.

To log simply use the code as your mentions. Use the import from java.util.logging.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...