GithubHelp home page GithubHelp logo

slf4gwt / slf4gwt Goto Github PK

View Code? Open in Web Editor NEW
6.0 5.0 3.0 68 KB

slf4j emulation for GWT

Home Page: https://www.slf4gwt.org

License: MIT License

Java 100.00%
slf4j-api gwt logging-framework slf4j-emulation

slf4gwt's Introduction

slf4gwt

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.

Motivation

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.

Inspiration

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.

Usage

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

Logging in development and production mode:

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

slf4gwt's People

Contributors

nbartels avatar thomas725 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

slf4gwt's Issues

Optional remote batch logger

We like to have an alternative remote logger, that can handle lists of LogRecords. So this allows us to implement a remote log handler that sends the log messages in batches to the server.

The server requests are reduced this way.

Additionally, we can add a filter to send only messages to the server that are above that log level. So it should be possible to log on INFO on the client and send only WARN or ERROR to the server.

Because this feature is optional, we add it as a new jar.

The configuration in the gwt.xml looks like:

<inherits name="org.slf4gwt.remote.batching.Enable" />
<set-property name="slf4gwt.log.remote.batch.minLogLevel" value="INFO"/>

slf4gwt 1.4 doesn't work with GWT 2.10.0

[INFO] GCLOUD: Caused by: 
[INFO] GCLOUD: java.lang.ClassNotFoundException: com.google.gwt.core.client.GWTBridge
[INFO] GCLOUD: 	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:476)
[INFO] GCLOUD: 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
[INFO] GCLOUD: 	at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:222)
[INFO] GCLOUD: 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
[INFO] GCLOUD: 	at org.slf4gwt.logging.impl.Impl.<clinit>(Impl.java:30)

The GWTBridge has been moved to com.google.gwt.core.shared.GWTBridge

gwt-log compatbility layer

Switching from gwt-log to slf4gwt can be problem if the gwt application is a big one and you don't want/have time to change all the loggers.

So we have to provide an compatibility layer, that provides the gwt-log packages and connects them to slf4gwt.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.