Link Search Menu Expand Document

Configuration

Table of contents

  1. Dependency managment
  2. Connect to your application
  3. Set the log level
  4. Define your appenders/handlers
  5. Development and production mode

Dependency managment

slf4gwt is listed on maven central and you can simply add the library to your dependencies as long as maven central is supported by your dependency management system. Maven itself supports maven central directly and so you only have to add these lines to your pom.xml. Please check maven central for other systems syntax.

<dependency>
    <groupId>org.slf4gwt</groupId>
    <artifactId>slf4gwt</artifactId>
    <version>1.4</version>
</dependency>

Connect to your application

To use slf4gwt in your application, you only have to add this inherits line to your gwt.xml file.

<inherits name="org.slf4gwt.logging.gwt.Logging"/>

Set the log level

The default log level for slf4gwt is INFO, but you can override it in your gwt.xml file by adding this line. Supported log levels are TRACE, DEBUG, INFO, WARN and ERROR.

<set-property name="slf4gwt.log.level" value="INFO"/>

Define your appenders/handlers

As with the originals slf4j, you can choose different appenders to which you pipe the log messages to. But in contrast to slf4j, the selected appenders are addressed in parallel and the output can thus be influenced via the following configuration.

<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" />

The shown example is the default configuration, console and developmentMode logging are enabled by default. Everything else is disabled. It’s up to you, to select a suitable appender configuration.

Development and production mode

Normally the JUL logging for GWT is enabled in development mode and disabled in production mode. Because we rely on this logging implementation, slf4gwt works exact the same way.

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).