Friday, February 25, 2011

Re: is it possible to use an SLF4J adapter in GWT to wrap java.util.logging ?

May I ask why do you need something like that? Basically everything
what you need is inside of gwt-user package.

Let's look what is actually SLF4J. It's just an interface for many
logging frameworks [java.lang, apache.logger , etc]. So when you have
plenty of libraries using different logging frameworks and want to
collect all these logs, you will use SLF4J for agregating these logs
to same format.

Now let's look what is inside gwt. There is pack with loggers to
firebug, jsconsole, system.out for dev mode, logger with remoteservice
to send logs to server. When you instantiate logger and make a log,
enabled frameworks are used. I agree thet format of log is horrible,
but inheriting this loggers and setting up own log formatter solve
this problem.

SO you just need familiar use of gwt logging. Make a class
LoggerFactory.getLogger ane one Logger class , make a mapping from
java.lang levels to SLF4J logger . - 2 classes and 1 class per log
channel.

Make it yourself.

On Feb 25, 12:50 pm, Thomas Broyer <t.bro...@gmail.com> wrote:
> On Friday, February 25, 2011 4:04:12 AM UTC+1, zixzigma wrote:
>
> > is it possible to use an SL4J adapter in GWT to wrap java.util.logging ?
>
> I started working on something like that at work, and we will eventually
> open source it.
>
> For now, I can use Slf4J in my client code. In DevMode, it will use whatever
> Slf4j implementation it finds in the classpath (which means that it will
> write to the console, not to the DevMode window), and it compiles out in
> prod mode.
> I've been thinking recently about just wrapping java.util.logging (and using
> jul-to-slf4j.jar to format my logs using logback) instead of my default,
> emulated NOPLoggerFactory (used in web mode only), but we actually don't use
> it that much in client code (and overall), so I didn't invest any more time
> in it for now.
>
> There's also a project on GitHub:https://github.com/derjan1982/slf4gwtmore
> like gwt-log than JUL integration in GWT though, IIRC.
>
> > I would like to be able to use logging.properties file to define
> > formatting,
> > which I believe is not possible with java.util.logging.
>
> I believe you can (at least in DevMode I mean, or when using a
> RemoteLogHandler), though you might have to make your own Formatter class
> (or pick a third-party one).

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment