Change of logging infrastructure

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Change of logging infrastructure

Till Rohrmann
Hi guys,

just a short remark about the new logging system we use henceforth in
Flink. We replaced jcl interface with slf4j and the log4j logging framework
with logback. The only things which change for you is the generation of the
logger and the configuration.

A logger with slf4j is created the following way:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Logger LOG = LoggerFactory.getLogger(Foobar.class)

In the context of this rework, we also disentangled Flink from the actually
used logging framework. This means that we got rid off the LogUtils. A
consequence of this change is that the logger is exclusively configured via
the configuration file logback.xml. This file has to be placed in the
classpath or given as an environment property
-Dlogback.configurationFile=<file> to the JVM.

Bests,

Till
Reply | Threaded
Open this post in threaded view
|

Re: Change of logging infrastructure

Robert Metzger
Cool.
How about adding a new page in the build-in documentation (docs/ directory)
that contains general remarks for developers (such as logging infra,
configuration, IDE, tooling etc.).




On Tue, Sep 2, 2014 at 8:29 PM, Till Rohrmann <[hidden email]> wrote:

> Hi guys,
>
> just a short remark about the new logging system we use henceforth in
> Flink. We replaced jcl interface with slf4j and the log4j logging framework
> with logback. The only things which change for you is the generation of the
> logger and the configuration.
>
> A logger with slf4j is created the following way:
>
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
>
> Logger LOG = LoggerFactory.getLogger(Foobar.class)
>
> In the context of this rework, we also disentangled Flink from the actually
> used logging framework. This means that we got rid off the LogUtils. A
> consequence of this change is that the logger is exclusively configured via
> the configuration file logback.xml. This file has to be placed in the
> classpath or given as an environment property
> -Dlogback.configurationFile=<file> to the JVM.
>
> Bests,
>
> Till
>
Reply | Threaded
Open this post in threaded view
|

Re: Change of logging infrastructure

Sebastian Schelter
Very nice!


2014-09-02 11:37 GMT-07:00 Robert Metzger <[hidden email]>:

> Cool.
> How about adding a new page in the build-in documentation (docs/ directory)
> that contains general remarks for developers (such as logging infra,
> configuration, IDE, tooling etc.).
>
>
>
>
> On Tue, Sep 2, 2014 at 8:29 PM, Till Rohrmann <[hidden email]>
> wrote:
>
> > Hi guys,
> >
> > just a short remark about the new logging system we use henceforth in
> > Flink. We replaced jcl interface with slf4j and the log4j logging
> framework
> > with logback. The only things which change for you is the generation of
> the
> > logger and the configuration.
> >
> > A logger with slf4j is created the following way:
> >
> > import org.slf4j.Logger;
> > import org.slf4j.LoggerFactory;
> >
> > Logger LOG = LoggerFactory.getLogger(Foobar.class)
> >
> > In the context of this rework, we also disentangled Flink from the
> actually
> > used logging framework. This means that we got rid off the LogUtils. A
> > consequence of this change is that the logger is exclusively configured
> via
> > the configuration file logback.xml. This file has to be placed in the
> > classpath or given as an environment property
> > -Dlogback.configurationFile=<file> to the JVM.
> >
> > Bests,
> >
> > Till
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Change of logging infrastructure

Henry Saputra
In reply to this post by Till Rohrmann
+1 awesome!

For debug level we should start using slf4j  parameterized logging to
avoid toString concatenation.

- Henry

On Tue, Sep 2, 2014 at 11:29 AM, Till Rohrmann <[hidden email]> wrote:

> Hi guys,
>
> just a short remark about the new logging system we use henceforth in
> Flink. We replaced jcl interface with slf4j and the log4j logging framework
> with logback. The only things which change for you is the generation of the
> logger and the configuration.
>
> A logger with slf4j is created the following way:
>
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
>
> Logger LOG = LoggerFactory.getLogger(Foobar.class)
>
> In the context of this rework, we also disentangled Flink from the actually
> used logging framework. This means that we got rid off the LogUtils. A
> consequence of this change is that the logger is exclusively configured via
> the configuration file logback.xml. This file has to be placed in the
> classpath or given as an environment property
> -Dlogback.configurationFile=<file> to the JVM.
>
> Bests,
>
> Till
Reply | Threaded
Open this post in threaded view
|

Re: Change of logging infrastructure

till.rohrmann
That's a very good point Henry. One of the advantages of slf4j is that it
avoids unnecessary string concatenations if used properly. By using
placeholders, slf4j builds the message string only if the log level is high
enough.

log.debug("This string contains {} placeholders and is only built if {}.",
2, "log level >= DEBUG")

We should encourage this usage and add it as a reference for future
contributors to the website.


On Tue, Sep 2, 2014 at 8:57 PM, Henry Saputra <[hidden email]>
wrote:

> +1 awesome!
>
> For debug level we should start using slf4j  parameterized logging to
> avoid toString concatenation.
>
> - Henry
>
> On Tue, Sep 2, 2014 at 11:29 AM, Till Rohrmann <[hidden email]>
> wrote:
> > Hi guys,
> >
> > just a short remark about the new logging system we use henceforth in
> > Flink. We replaced jcl interface with slf4j and the log4j logging
> framework
> > with logback. The only things which change for you is the generation of
> the
> > logger and the configuration.
> >
> > A logger with slf4j is created the following way:
> >
> > import org.slf4j.Logger;
> > import org.slf4j.LoggerFactory;
> >
> > Logger LOG = LoggerFactory.getLogger(Foobar.class)
> >
> > In the context of this rework, we also disentangled Flink from the
> actually
> > used logging framework. This means that we got rid off the LogUtils. A
> > consequence of this change is that the logger is exclusively configured
> via
> > the configuration file logback.xml. This file has to be placed in the
> > classpath or given as an environment property
> > -Dlogback.configurationFile=<file> to the JVM.
> >
> > Bests,
> >
> > Till
>
Reply | Threaded
Open this post in threaded view
|

Re: Change of logging infrastructure

Ufuk Celebi-2
Nice! :)

Issue [1] and PR [2], respectively.

[1] https://issues.apache.org/jira/browse/FLINK-1086
[2] https://github.com/apache/incubator-flink/pull/111


On Wed, Sep 3, 2014 at 7:00 AM, Till Rohrmann <[hidden email]>
wrote:

> That's a very good point Henry. One of the advantages of slf4j is that it
> avoids unnecessary string concatenations if used properly. By using
> placeholders, slf4j builds the message string only if the log level is high
> enough.
>
> log.debug("This string contains {} placeholders and is only built if {}.",
> 2, "log level >= DEBUG")
>
> We should encourage this usage and add it as a reference for future
> contributors to the website.
>
>
> On Tue, Sep 2, 2014 at 8:57 PM, Henry Saputra <[hidden email]>
> wrote:
>
> > +1 awesome!
> >
> > For debug level we should start using slf4j  parameterized logging to
> > avoid toString concatenation.
> >
> > - Henry
> >
> > On Tue, Sep 2, 2014 at 11:29 AM, Till Rohrmann <[hidden email]>
> > wrote:
> > > Hi guys,
> > >
> > > just a short remark about the new logging system we use henceforth in
> > > Flink. We replaced jcl interface with slf4j and the log4j logging
> > framework
> > > with logback. The only things which change for you is the generation of
> > the
> > > logger and the configuration.
> > >
> > > A logger with slf4j is created the following way:
> > >
> > > import org.slf4j.Logger;
> > > import org.slf4j.LoggerFactory;
> > >
> > > Logger LOG = LoggerFactory.getLogger(Foobar.class)
> > >
> > > In the context of this rework, we also disentangled Flink from the
> > actually
> > > used logging framework. This means that we got rid off the LogUtils. A
> > > consequence of this change is that the logger is exclusively configured
> > via
> > > the configuration file logback.xml. This file has to be placed in the
> > > classpath or given as an environment property
> > > -Dlogback.configurationFile=<file> to the JVM.
> > >
> > > Bests,
> > >
> > > Till
> >
>