-1

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.

muescha
  • 1,544
  • 2
  • 12
  • 22
aaryan
  • 1
  • 1
  • 3

3 Answers3

1

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.

Hilbrand Bouwkamp
  • 13,509
  • 1
  • 45
  • 52
0

On the client side, GWT compiles to Javascript, and Javascript cannot in general write files to the client's filesystem. (It should be obvious why this could be a bad idea). See for example this discussion.

If what you need is logs to use for debugging, one obvious solution is to have the logger append to a text area on the page. You can always copy and past manually into another file. Or, if you want to debug remotely, you could have the logger write to the server.

Russell Zahniser
  • 16,188
  • 39
  • 30
  • I know that things , but my question was , how can i log client side activities in a log file ? How to use SimpleRemoteHandler provided by GWT. – aaryan Feb 25 '12 at 14:15
0

Just create a RPC service to log it into the server-side.

Use the servlet-side threadlocal to get info about the client: ThreadLocal to store ServletRequest and Response in servlet: what for?.

Community
  • 1
  • 1
Blessed Geek
  • 21,058
  • 23
  • 106
  • 176