[slf4j-dev] [Bug 31] Varargs for Logger methods

bugzilla-daemon at pixie.qos.ch bugzilla-daemon at pixie.qos.ch
Wed Sep 7 16:57:11 CEST 2011


http://bugzilla.slf4j.org/show_bug.cgi?id=31

--- Comment #94 from John Vasileff <git at netcc.us> 2011-09-07 16:57:10 CEST ---
(In reply to comment #91)
> I see 3 possibilities to dealing with changes in SLF4J:

> 0) disallow any meaningful changes to SLF4J
> 1) allow for breaking compatibility for adapter implementations (as done
> historically in SLF4J)
> 2) come up with an abstraction so flexible that it is future proof for the next
> 10 years.

> 0 and 1 are doable. 2 requires great foresight.

I suppose it is imposible to guarantee #2, but at least we can try!

It may help to distill the contract between SLF4J and logger/adapter
implementations into the fundamentals.  An intial attempt:

Adapters require access to:
    - The level & marker
    - The raw & formatted messages (raw for filtering only?)
    - The throwable, if exists
    - The processed arguments (strip trailing throwable).  For performance
      reasons, adapters may also have access to the raw arguments.  Sharing
      unpressed arguments is a performance tradeoff and should be avoided when
      possible.

SLF4J requires from adapters:
    - isEnabled(marker, level)
    - ability to submit logs to adapters (obviously)

Division of responsibilities:
    - SLF4J should fully control formatting, if applied.  Allowing individual
      implementations to control the style of formatting violates the pluggable
      nature of back end logging frameworks.
    - SLF4J should fully control the application facing API.
    - SLF4J reserves the right to provide additional functionality so long as
      "Adapters require access to" points are satisfied (XLogger).

I think the pros/cons of pluggable formatting is a separate debate, but
providing a framework for things like this is relevant.  The proposed
Abstract[Raw]Logger would allow for future enhancements like:

Logger myLogger = LoggerFactory.getLogger(MyClass.class)
        .formatWith(SLF4JFormatters.JAVA_UTIL_FORMATTER);

or even:

Logger myLogger = LoggerFactory.getLogger(MyClass.class)
        .formatWith(myFormatterInstance implements SLF4JFormatter);

-- 
Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the slf4j-dev mailing list