slf4gwt is a slf4j emulation for GWT. With this project it is possible for a Java developer to use the slf4j API on the GWT client side. So it is possible to use slf4j on server and client code.
On server code it is a common practice to use slf4j to hide the used logging framework. On GWT client side slf4j cannot be used and so it is up to the developer to keep an eye on her code and check where it runs. Especially shared code is a problem here. The solution for the problem is slf4gwt and the slf4j api is used on client and server side.
Like the well-known slf4j, sl4fgwt uses a logging framework to write the logging messages. GWT provides a java.util.logging implementation, and we use this implementation to write the messages to the right appender.
slf4gwt is inspired by some other open source projects. The most important one is gwt-log the former number one logging framework for GWT. It was used before GWT 2.1 very often. Next we like slf4j-gwt a lot but the implementation stopped some years ago, and slf4gwt likes to bridge the gap and provide a state of the art version, that can be used with the current GWT implementations.
First you need to import the jar into your project.
<dependency>
<groupId>org.slf4gwt</groupId>
<artifactId>slf4gwt</artifactId>
<version>1.4</version>
</dependency>
Then add the logging module to your module (*.gwt.xml):
<inherits name="org.slf4gwt.logging.gwt.Logging"/>
You can also set logging level (TRACE, DEBUG, INFO, WARN, ERROR):
<set-property name="slf4gwt.log.level" value="INFO"/>
And you can configure the used appenders:
<set-property name="slf4gwt.log.handler.console" value="ENABLED" />
<set-property name="slf4gwt.log.handler.developmentMode" value="ENABLED" />
<set-property name="slf4gwt.log.handler.hasWidgets" value="DISABLED" />
<set-property name="slf4gwt.log.handler.system" value="DISABLED" />
<set-property name="slf4gwt.log.handler.simpleRemote" value="DISABLED" />
Normally the logging is enabled in development mode and disabled in production mode. If you need to get logs on production mode, you have to enable the GWT logging as defined on the GWT logging manual. Or simply add this line to you *.gwt.xml file:
<set-property name="gwt.logging.enabled" value="TRUE"/>
Possible values are TRUE
, WARNING
, SEVERE
and FALSE
(if you don't need any logging at all).