Saturday, January 22, 2011

How to programmatically log errors, warnings and info messages in google app engine

Google app engine documentation provides info on how to log server side errors, warnings or info messages in Python environment but there is no clear documentation on how to do the same in java environment. Here is an example of logging in java environment

import java.util.logging.Logger;
private static final Logger log = Logger

.getLogger(MyClass.class.getName());
public class MyClass {

public myMethod() {
 
                        log.info("Informational message");

                        log.warning("warning");
log.severe("severe error");


}

}

When deployed to App Engine, you can find the logs app engine admin console



In Dev mode (if using Eclipse), you can see the logs on Eclipse console