One of the new functionality implemented into GWT 2.1 M2 is a Java logging API. The development team doesn't choose to implements a new API, but to use the logging API provided by Java SDK by emulating it. So, to use it, you just should create a logger as usual in your class and use it like that:
public class Gwt_log implements EntryPoint {
// create the logger
private static final Logger logger = Logger.getLogger(Gwt_log.class.getName());
public void onModuleLoad() {
// use it
logger.info("Module is loading");
}
}
As usual in GWT, your module, to use this API, must inherit from the logging module:
<inherits name='com.google.gwt.logging.Logging'/>
- gwt.logging.enabled: enable or disable logging API, set to TRUE by default,
- gwt.logging.logLevel: logging level, by default, set to INFO. Other available values are: ALL, FINEST, FINER, FINE, CONFIG, INFO, WARNING, SEVERE,
- gwt.logging.consoleHandler: log message into the IDE console, by default, set to ENABLED. It doesn't have any effect in production mode,
- gwt.logging.developmentModeHandler: log message into dev mode console. By default, set to ENABLED,
- gwt.logging.firebugHandler: log message into Fiebug console. By default, set to ENABLED,
- gwt.logging.popupHandler: log message into a popup window into the GWT application. By default, set to ENABLED,
- gwt.logging.systemHandler: log message with a level upper than WARNING on System.err, else, on System.out. By default, set to ENABLED,
- gwt.logging.simpleRemoteHandler: log message on server side by using a service defined by GWT. By default, set to ENABLED.
<servlet>
<servlet-name>remoteLogger</servlet-name>
<servlet-class>com.google.gwt.logging.server.RemoteLoggingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>remoteLogger</servlet-name>
<url-pattern>/gwt_log/remote_logging</url-pattern>
</servlet-mapping>
In future post, I will explain how to use the MVP framework, the validation API, the new paging table widgets, and the new binding mechanism between client and server.
For other feature, have a look to: GWT 2.1: validation API.
No comments:
Post a Comment