File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes GWT and the fly likes GWT Logging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "GWT Logging " Watch "GWT Logging " New topic
Author

GWT Logging

Vikas Pandit
Greenhorn

Joined: May 30, 2013
Posts: 5
Hi All,
How can i write log message in a file (/WEB-INF/logs) in GWT? it seems log4j is not supported but then i wrote a servlet (to be loaded when application starts to load my custom "logging.properties"(from /WEB-INF/classes/logging.properties) file and load it into java.util.LogManager but i get below error

java.lang.NoClassDefFoundError: java.util.logging.LogManager is a restricted class. Please see the Google App Engine developer's guide for more details.

my point here is to write log messages into a file under /WEB-INF/logs.

Thanks,
Vikas.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10355
    
    8

Welcome to the Ranch.

GWT is client side technology and WEB-INF/logs would indicate the server. Also Please see the Google App Engine developer's guide for more details indicates you are using GAE.
So what are you using exactly? GWT hosted on Tomcat or GWT with GAE?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Vikas Pandit
Greenhorn

Joined: May 30, 2013
Posts: 5
Hi Maneesh,
Thanks for your reply. actually i just started learning GWT and my whole point is to log all messages into file whether its on Entry point or on service/DAO layer the way we do in struts (control, service & DAO layer) on tomcat.

Thanks,
Vikas
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10355
    
    8

Like I mentioned GWT is client side and you cannot log to the server from your client. Thats the reason I asked you
So what are you using exactly? GWT hosted on Tomcat or GWT with GAE?


If you are using GWT+Tomcat or something similar you can use log4j in the usual way.
If you are using GAE as your back end check out https://developers.google.com/appengine/articles/logging
You might also want to check out https://developers.google.com/web-toolkit/doc/latest/DevGuideLogging

Vikas Pandit
Greenhorn

Joined: May 30, 2013
Posts: 5
Hi Maneesh,
So of an application is running in prod on tomcat and i want to see all my log messages then as per your last mail i should go for log4j?
What is the GWT standard for logging in prod to log client and server messages to file?
Also when i try to integrate log4j i get below error.

No source code is available for type org.apache.log4j.Logger; did you forget to inherit a required module?

Thanks,
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10355
    
    8

Did you check the links I posted, especially the second one?
Vikas Pandit
Greenhorn

Joined: May 30, 2013
Posts: 5
Yes i did...i can understand all the logging what GWT supports but my question is how can i write all my logging messages to a File on client & server both side. Please share any example where i can write all log messages to a file.

IS IT POSSIBLE OR NOT, IN GWT???

Thanks,
Vikas
Vikas Pandit
Greenhorn

Joined: May 30, 2013
Posts: 5
i wrote a simple program using java logging framework which i want to use in GWT to write log messages int file.

# The following creates two handlers
handlers=java.util.logging.ConsoleHandler, java.util.logging.FileHandler

# Set the default logging level for the root logger
.level=SEVERE
# log level for the "com.rst.example" package
com.maxima.level=INFO

# Set the default logging level
java.util.logging.ConsoleHandler.level=ALL
java.util.logging.FileHandler.level=INFO

# Set the default formatter
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter

# Specify the location and name of the log file
java.util.logging.FileHandler.pattern=C:/sample/log/log-test.log

java.util.logging.FileHandler.limit=50000
java.util.logging.FileHandler.append=true
java.util.logging.FileHandler.count=1

==========================
package com.maxima;
import java.util.logging.*;
import java.io.*;
public class TestLogeer{
static{
try{
File f = new File("C:\\sample\\log\\logging.properties");
System.out.println("File Exists\t"+f.exists());
LogManager.getLogManager().readConfiguration(new FileInputStream(f));
}catch(Exception e){
System.out.println("Exception\t"+e);
}
}
private static final Logger LOG = Logger.getLogger(TestLogeer.class.getName());
public TestLogeer(){
}
public void writeLog(){
LOG.info("First Message");
}
public static void main(String ar[]){
TestLogeer tl = new TestLogeer();
tl.writeLog();
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GWT Logging