Changing how logging works starting from 2.4?

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

Changing how logging works starting from 2.4?

Daniel Dekany
Currently FreeMarker looks for logging libraries in this order (by
default) with the class-loader of the FreeMarker classes:

  Log4J, Avalon, java.util.logging

The first that it founds in this list will be the one used for
logging.

I propose that starting from 2.3 we add support for SLF4J and
commons-logging. In 2.3 these would go to the *end* of the searching
list for backward compatibility, but one can still force using SLF4J
or commons-logging like this:

   freemarker.log.Logger.selectLoggerLibrary(freemarker.log.Logger.LIBRARY_SLF4J);

But starting from 2.4 the order should be changed to:

  SLF4J, commons-logging, Log4J, Avalon, java.util.logging

so the two widespread logger adapters would take priority. That would
be useful because it's common that these adapters are used to
"redirect" all the log messages of all components of the application
to a central concrete logger library.

Opinions?

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing how logging works starting from 2.4?

Guo Du-4
On Sun, Jul 25, 2010 at 10:48 PM, Daniel Dekany <[hidden email]> wrote:
>  SLF4J, commons-logging, Log4J, Avalon, java.util.logging
+1 for SLF4J on the first

-Guo

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing how logging works starting from 2.4?

Daniel Dekany
Monday, July 26, 2010, 12:35:57 AM, Guo Du wrote:

> On Sun, Jul 25, 2010 at 10:48 PM, Daniel Dekany <[hidden email]> wrote:
>>  SLF4J, commons-logging, Log4J, Avalon, java.util.logging
> +1 for SLF4J on the first

BTW, that FM has no SLF4J support currently also means that it doesn't
support Logback, which starts to become an important player. Yet
nobody has complained so far.

What I find more puzzling is that AFAIR nobody has ever complained
about that FM logging has to be configured separately, while the
logging of virtually all other libraries can be configured at once by
setting up SLF4J and commons-logging. (This is why I used to say
regarding the more-eyeballs-see-more theory that if you are using your
own software that worths more than all those millions of users
eyeballs. No way FM would get away with this if I use it on
server-side nowadays... Anyway, now I noticed, so it will be fixed.)

> -Guo

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing how logging works starting from 2.4?

Daniel Dekany
In reply to this post by Daniel Dekany
I just went ahead and did this.

A little difference to what I said earlier is that under 2.3 (and
2.3-gae) SLF4J and Commons Logging is *never* selected automatically
for backward-compatibility reasons [*].

So, to recap, on 2.3.17 and 2.3-gae latest nightly you can use this
to use SLF4 or Commons Logging:

  import freemarker.log.Logger;
  ...
      // IMPORTANT: This should be executed before using other FreeMarker classes!
      Logger.selectLoggerLibrary(Logger.LIBRARY_SLF4J);  // or Logger.LIBRARY_COMMONS
  ...

Starting from 2.4 (and so in 3.0 too) if you have SLF4 in the class
path, FM will use that automatically, no mater what else you have in
the class path. Next in priority is Apache Commons Logging. Only after
these come Log4J, Avalong, and java.util.logging.


* Why not automatically choosing SL4J etc on 2.3-s: The presence of
  java.util.logging depends on the Java version, and the new logger
  had to go after java.util.logging for BC... so it would lead to some
  mean unforeseeable bugs in applications, since the behavior depends
  on if you install it on Java 1.3 VS Java 1.4. And if it's on 1.4+,
  then java.util.logging would always take over anyway. Plus after
  java.util.logging FreeMarker has chosen the "Null logger", and now
  it would instead start harassing the user with log messages on the
  consol or something... also not very BC.

--
Best regards,
 Daniel Dekany

Sunday, July 25, 2010, 11:48:16 PM, Daniel Dekany wrote:

> Currently FreeMarker looks for logging libraries in this order (by
> default) with the class-loader of the FreeMarker classes:
>
>   Log4J, Avalon, java.util.logging
>
> The first that it founds in this list will be the one used for
> logging.
>
> I propose that starting from 2.3 we add support for SLF4J and
> commons-logging. In 2.3 these would go to the *end* of the searching
> list for backward compatibility, but one can still force using SLF4J
> or commons-logging like this:
>
>  
> freemarker.log.Logger.selectLoggerLibrary(freemarker.log.Logger.LIBRARY_SLF4J);
>
> But starting from 2.4 the order should be changed to:
>
>   SLF4J, commons-logging, Log4J, Avalon, java.util.logging
>
> so the two widespread logger adapters would take priority. That would
> be useful because it's common that these adapters are used to
> "redirect" all the log messages of all components of the application
> to a central concrete logger library.
>
> Opinions?
>


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing how logging works starting from 2.4?

Guo Du-4
On Tue, Jul 27, 2010 at 1:27 PM, Daniel Dekany <[hidden email]> wrote:
>      // IMPORTANT: This should be executed before using other FreeMarker classes!
>      Logger.selectLoggerLibrary(Logger.LIBRARY_SLF4J);  // or Logger.LIBRARY_COMMONS
The fixed logger constants stop FM to support new logger once shipped.
We could add a new method to pass a LoggerFactory class which leave
space for user to add new logger implementation:
public static Logger.selectLoggerFactory(Class loggerFactoryClass)

This won't break the backward compatibility for 2.3.X steam as well.

What do you think?

-Guo

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing how logging works starting from 2.4?

Daniel Dekany
Tuesday, July 27, 2010, 2:56:51 PM, Guo Du wrote:

> On Tue, Jul 27, 2010 at 1:27 PM, Daniel Dekany <[hidden email]> wrote:
>>      // IMPORTANT: This should be executed before using other FreeMarker classes!
>>      Logger.selectLoggerLibrary(Logger.LIBRARY_SLF4J);  // or Logger.LIBRARY_COMMONS
> The fixed logger constants stop FM to support new logger once shipped.
> We could add a new method to pass a LoggerFactory class which leave
> space for user to add new logger implementation:
> public static Logger.selectLoggerFactory(Class loggerFactoryClass)
>
> This won't break the backward compatibility for 2.3.X steam as well.
>
> What do you think?

Yeah, that sounds good. Although, frankly, I doubt it's a high enough
priority task in my FM TODO list, not even if I it to logging related
issues. Most libraries just use either Apache Commons Logging or
SLF4J, hard-wired, and that's it. So these logger-wrappers (which can
also feed in-house logger solutions) won't go away anytime soon, if
ever.

> -Guo

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing how logging works starting from 2.4?

Guo Du-4
On Tue, Jul 27, 2010 at 2:20 PM, Daniel Dekany <[hidden email]> wrote:
> Yeah, that sounds good. Although, frankly, I doubt it's a high enough
> priority task in my FM TODO list, not even if I it to logging related
> issues. Most libraries just use either Apache Commons Logging or
> SLF4J, hard-wired, and that's it. So these logger-wrappers (which can
> also feed in-house logger solutions) won't go away anytime soon, if

No push to have it in 2.3.x. Most of application environment will
support at least one of exist logger, that's why no people require
sl4j.

It is good enough for new code base to have the extension capability.

-Guo

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing how logging works starting from 2.4?

Daniel Dekany
Tuesday, July 27, 2010, 4:44:15 PM, Guo Du wrote:

> On Tue, Jul 27, 2010 at 2:20 PM, Daniel Dekany <[hidden email]> wrote:
>> Yeah, that sounds good. Although, frankly, I doubt it's a high enough
>> priority task in my FM TODO list, not even if I it to logging related
>> issues. Most libraries just use either Apache Commons Logging or
>> SLF4J, hard-wired, and that's it. So these logger-wrappers (which can
>> also feed in-house logger solutions) won't go away anytime soon, if
>
> No push to have it in 2.3.x. Most of application environment will
> support at least one of exist logger, that's why no people require
> sl4j.
>
> It is good enough for new code base to have the extension capability.

Sorry, I don't get why's that useful in practice. If someone
introduces a new logging library, they should implement either SLF4J
or Commons Logging instead of the FreeMarker-specific interfaces. Then
at least other libraries will be able to use the new logging library
too. Thus be supporting this two interfaces in FreeMarker, we now
support all future logging frameworks already, don't we? (OK,
theoretically somebody could invent yet another logging library
wrapper library, but... well, let's hope SLF4J is awesome enough so
that it won't happen.)

> -Guo

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing how logging works starting from 2.4?

Guo Du-4
On Tue, Jul 27, 2010 at 5:08 PM, Daniel Dekany <[hidden email]> wrote:
> Sorry, I don't get why's that useful in practice. If someone
> introduces a new logging library, they should implement either SLF4J
> or Commons Logging instead of the FreeMarker-specific interfaces. Then
It just give user options. You never know SLF4J will be the last
logger api FM want to support :)

I understand FM logger was designed to have independent logger
provider, but now a days logger is common used everywhere, not sure
it's necessary to have another logger wrapper layer inside FM. It may
be good to just use SLF4J api directly instead FM logger for next
major release.

-Guo

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing how logging works starting from 2.4?

Daniel Dekany
Wednesday, July 28, 2010, 12:03:50 AM, Guo Du wrote:

> On Tue, Jul 27, 2010 at 5:08 PM, Daniel Dekany <[hidden email]> wrote:
>> Sorry, I don't get why's that useful in practice. If someone
>> introduces a new logging library, they should implement either SLF4J
>> or Commons Logging instead of the FreeMarker-specific interfaces. Then
> It just give user options. You never know SLF4J will be the last
> logger api FM want to support :)
>
> I understand FM logger was designed to have independent logger
> provider, but now a days logger is common used everywhere, not sure
> it's necessary to have another logger wrapper layer inside FM. It may
> be good to just use SLF4J api directly instead FM logger for next
> major release.

Yeah, that's what Attila has suggested for 3.0: drop freemarker.log
and just use SLF4J directly instead. Back then I questioned this
proposal, as we already have freemarker.log, so removing it would not
give anything to the users, only get away some features (even if
marginal ones). However, now I realize that using SLF4J directly would
fix the issue where the origin of the log messages is shown to be the
line in our logger adapter, while it should be the line where the
freemareker.log.Logger.<level>(...) method was called from. (Sadly,
the SLF4J API doesn't have anything where I could instruct it to skip
freemarker.log.SLF4JLoggerFactory$SLF4JLogger in the stack-trace, so I
can't fix this. (Unless I miss something...))

> -Guo

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing how logging works starting from 2.4?

Guo Du-4
On Wed, Jul 28, 2010 at 11:43 AM, Daniel Dekany <[hidden email]> wrote:
> and just use SLF4J directly instead. Back then I questioned this
> proposal, as we already have freemarker.log, so removing it would not
> give anything to the users, only get away some features (even if
> marginal ones). However, now I realize that using SLF4J directly would
> fix the issue where the origin of the log messages is shown to be the

It's an excellent movement: keep the core and drop feature we are not
good at. Cache may be another area we can have similar approach. We
will have less but quality code which is great :)

-Guo

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing how logging works starting from 2.4?

Carey Evans
In reply to this post by Daniel Dekany
In article <[hidden email]>, [hidden email]
says...
> (Sadly,
> the SLF4J API doesn't have anything where I could instruct it to skip
> freemarker.log.SLF4JLoggerFactory$SLF4JLogger in the stack-trace, so I
> can't fix this. (Unless I miss something...))

An SLF4J Logger implementation may implement LocationAwareLogger, which
provides one method that takes the log adapter's class name. It's
usually used by the Log4J and JCL adapters so that they're not listed as
the caller.

(The existence of these adapters is probably why there's not much demand
for Freemarker to use SLF4J.)


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing how logging works starting from 2.4?

Daniel Dekany
Thursday, July 29, 2010, 7:19:34 AM, Carey Evans wrote:

> In article <[hidden email]>, [hidden email]
> says...
>> (Sadly,
>> the SLF4J API doesn't have anything where I could instruct it to skip
>> freemarker.log.SLF4JLoggerFactory$SLF4JLogger in the stack-trace, so I
>> can't fix this. (Unless I miss something...))
>
> An SLF4J Logger implementation may implement LocationAwareLogger, which
> provides one method that takes the log adapter's class name. It's
> usually used by the Log4J and JCL adapters so that they're not listed as
> the caller.

Right, I have overlooked that... now it's implemented. Thanks!

> (The existence of these adapters is probably why there's not much demand
> for Freemarker to use SLF4J.)

True, the is a slf4j-over-log4j adapter. (Although it was still lame
that it had to be present, and only because of FreeMarker...)

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing how logging works starting from 2.4?

Daniel Dekany
In reply to this post by Guo Du-4
Wednesday, July 28, 2010, 1:37:44 PM, Guo Du wrote:

> On Wed, Jul 28, 2010 at 11:43 AM, Daniel Dekany <[hidden email]> wrote:
>> and just use SLF4J directly instead. Back then I questioned this
>> proposal, as we already have freemarker.log, so removing it would not
>> give anything to the users, only get away some features (even if
>> marginal ones). However, now I realize that using SLF4J directly would
>> fix the issue where the origin of the log messages is shown to be the
>
> It's an excellent movement: keep the core and drop feature we are not
> good at. Cache may be another area we can have similar approach. We
> will have less but quality code which is great :)

Well, now the SLF4J logging shows the locations correctly even when
using it through the freemarker.log, so... my earlier reason for
removing it doesn't stand anymore.

> -Guo

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel